Skip to content

Commit

Permalink
chore: empty modals export w/ deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
oedotme committed Apr 12, 2024
1 parent b3dd185 commit 03d4b27
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
7 changes: 5 additions & 2 deletions packages/generouted/src/react-router-lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ const _404 = preservedRoutes?.['404']

const Default = _app?.default || Outlet

const Modals = () => {
const Modals_ = () => {
const Modal = modalRoutes[useLocation().state?.modal] || Fragment
return <Modal />
}

const Layout = () => (
<>
<Default /> <Modals />
<Default /> <Modals_ />
</>
)

Expand All @@ -58,3 +58,6 @@ const fallback = { path: '*', Component: _404?.default || Fragment }
export const routes: RouteObject[] = [{ ...app, children: [...regularRoutes, fallback] }]
const router = createBrowserRouter(routes)
export const Routes = () => <RouterProvider router={router} />

/** @deprecated `<Modals />` is no longer needed, it will be removed in future releases */
export const Modals = () => (console.warn('[generouted] `<Modals />` will be removed in future releases'), null)
7 changes: 5 additions & 2 deletions packages/generouted/src/react-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ const _404 = preservedRoutes?.['404']

const Default = _app?.default || Outlet

const Modals = () => {
const Modals_ = () => {
const Modal = modalRoutes[useLocation().state?.modal] || Fragment
return <Modal />
}

const Layout = () => (
<>
<Default /> <Modals />
<Default /> <Modals_ />
</>
)

Expand All @@ -45,3 +45,6 @@ const fallback = { path: '*', Component: _404?.default || Fragment }
export const routes: RouteObject[] = [{ ...app, children: [...regularRoutes, fallback] }]
const router = createBrowserRouter(routes)
export const Routes = () => <RouterProvider router={router} />

/** @deprecated `<Modals />` is no longer needed, it will be removed in future releases */
export const Modals = () => (console.warn('[generouted] `<Modals />` will be removed in future releases'), null)
7 changes: 5 additions & 2 deletions packages/generouted/src/solid-router-lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ const Fragment = (props: ParentProps) => props?.children
const Default = _app?.default || Fragment
const Pending = _app?.Pending || Fragment
const Catch = preservedRoutes?.['_app']?.Catch
const Modals = () => createMemo(() => modalRoutes[useLocation<any>().state?.modal || ''] || Fragment) as any
const Modals_ = () => createMemo(() => modalRoutes[useLocation<any>().state?.modal || ''] || Fragment) as any

const Layout = (props: ParentProps) => (
<>
<Default {...props} /> <Modals />
<Default {...props} /> <Modals_ />
</>
)

Expand All @@ -57,3 +57,6 @@ const fallback: RouteDefinition = { path: '*', component: _404?.default || Fragm

export const routes: RouteDefinition[] = [{ ...app, children: [...regularRoutes, fallback] }]
export const Routes = () => <Router>{routes}</Router>

/** @deprecated `<Modals />` is no longer needed, it will be removed in future releases */
export const Modals = () => (console.warn('[generouted] `<Modals />` will be removed in future releases'), null)
7 changes: 5 additions & 2 deletions packages/generouted/src/solid-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const Fragment = (props: ParentProps) => props?.children
const Default = _app?.default || Fragment
const Pending = _app?.Pending || Fragment
const Catch = preservedRoutes?.['_app']?.Catch
const Modals = () => createMemo(() => modalRoutes[useLocation<any>().state?.modal || ''] || Fragment) as any
const Modals_ = () => createMemo(() => modalRoutes[useLocation<any>().state?.modal || ''] || Fragment) as any

const Layout = (props: ParentProps) => (
<>
<Default {...props} /> <Modals />
<Default {...props} /> <Modals_ />
</>
)

Expand All @@ -56,3 +56,6 @@ const fallback: RouteDefinition = { path: '*', component: _404?.default || Fragm

export const routes: RouteDefinition[] = [{ ...app, children: [...regularRoutes, fallback] }]
export const Routes = () => <Router>{routes}</Router>

/** @deprecated `<Modals />` is no longer needed, it will be removed in future releases */
export const Modals = () => (console.warn('[generouted] `<Modals />` will be removed in future releases'), null)

0 comments on commit 03d4b27

Please sign in to comment.