Skip to content

Commit

Permalink
feat: InnerWrap option
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Dec 14, 2023
1 parent 369bcb1 commit 8b631d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/react-router/src/RouterProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,26 @@ export function RouterProvider<
},
} as any)

const inner = (
<routerContext.Provider value={router}>
const matches = router.options.InnerWrap ? (
<router.options.InnerWrap>
<Matches />
</router.options.InnerWrap>
) : (
<Matches />
)

const provider = (
<routerContext.Provider value={router}>
{matches}
<Transitioner />
</routerContext.Provider>
)

if (router.options.Wrap) {
return <router.options.Wrap>{inner}</router.options.Wrap>
return <router.options.Wrap>{provider}</router.options.Wrap>
}

return inner
return provider
}

function Transitioner() {
Expand Down
1 change: 1 addition & 0 deletions packages/react-router/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export interface RouterOptions<
routeMasks?: RouteMask<TRouteTree>[]
unmaskOnReload?: boolean
Wrap?: (props: { children: any }) => JSX.Element
InnerWrap?: (props: { children: any }) => JSX.Element
notFoundRoute?: AnyRoute
}

Expand Down

0 comments on commit 8b631d9

Please sign in to comment.