-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Loving this package so far. I generally prefer to have modals routed though rather than state based in order to have shareable links as a default, rather than state-based (which are only good for global routes).
I have managed to do this myself with custom routes file:
E.g., I have a route in pages/companies/+edit.[id].tsx
And then in routes file I do this to render modals for routes, following the internal matching engine of react-router-dom:
const modalsArray = Object.entries(modalRoutes).map(([path, Component]) => ({
path: path
.replace(...patterns.route)
.replace(...patterns.splat)
.replace(...patterns.param)
.replace(/(^|\/)\-\:(:?[\w-]+)(\/|$)/, '$1$2?'),
element: <Component />,
}))
export const Modals = () => {
const location = useLocation()
const matches = matchRoutes(modalsArray, location)
return renderMatches(matches)
}
Would be great to have this with type-safety out of the box for linkable routes with params.
redbar0n, S4GU4R0 and FrancoRATOVOSONoedotme, suiramdev and FrancoRATOVOSON
Metadata
Metadata
Assignees
Labels
No labels