forked from redwoodjs/redwood
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:redwoodjs/redwood into feat/move-se…
…rver-store * 'main' of github.com:redwoodjs/redwood: chore(deps): bump @fastify/reply-from from 9.4.0 to 9.8.0 (redwoodjs#10728) chore(deps): bump jose from 4.15.4 to 4.15.5 (redwoodjs#10726) chore(ci): Track `@redwoodjs/router` in RSC CI (redwoodjs#10727) chore(deps): bump ejs from 3.1.9 to 3.1.10 (redwoodjs#10725) RSC: Include `<App>` in SSR (redwoodjs#10688) chore(logging): Remove overly verbose logging (redwoodjs#10723) chore(formatting): Fix "check annotations" (redwoodjs#10722) chore(comment): Update comment to match implementation (redwoodjs#10720) chore(imports): Differentiate between React type import and method imports (redwoodjs#10721) chore(auth): auth-supabase-api dependency fixes (redwoodjs#10719)
- Loading branch information
Showing
29 changed files
with
540 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// TODO (RSC): This should live in @redwoodjs/router I think. But we should | ||
// figure out what to do with ClientRouter first, and then we can think about | ||
// this file. | ||
|
||
import React, { useMemo } from 'react' | ||
|
||
import { analyzeRoutes } from '@redwoodjs/router/dist/analyzeRoutes' | ||
import { LocationProvider, useLocation } from '@redwoodjs/router/dist/location' | ||
import { namedRoutes } from '@redwoodjs/router/dist/namedRoutes' | ||
import type { RouterProps } from '@redwoodjs/router/dist/router' | ||
|
||
import { renderRoutesFromDist } from './clientSsr' | ||
|
||
export const Router = ({ paramTypes, children }: RouterProps) => { | ||
return ( | ||
<LocationProvider> | ||
<LocationAwareRouter paramTypes={paramTypes}> | ||
{children} | ||
</LocationAwareRouter> | ||
</LocationProvider> | ||
) | ||
} | ||
|
||
const LocationAwareRouter = ({ paramTypes, children }: RouterProps) => { | ||
const { pathname } = useLocation() | ||
|
||
const { namedRoutesMap } = useMemo(() => { | ||
return analyzeRoutes(children, { | ||
currentPathName: pathname, | ||
userParamTypes: paramTypes, | ||
}) | ||
}, [pathname, children, paramTypes]) | ||
|
||
// Assign namedRoutes so it can be imported like import {routes} from 'rwjs/router' | ||
// Note that the value changes at runtime | ||
Object.assign(namedRoutes, namedRoutesMap) | ||
|
||
return renderRoutesFromDist(pathname) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.