import type { FC, PropsWithChildren } from 'react'; import { useMemo } from 'react'; import { MemoryRouter, Route, Routes } from 'react-router'; export type MemoryRouterWithParamsProps = PropsWithChildren<{ params: Record; }>; /** * Wrap any component using useParams() with MemoryRouterWithParams, in order to determine wat the hook should return */ export const MemoryRouterWithParams: FC = ({ children, params }) => { const pathname = useMemo(() => `/${Object.values(params).join('/')}`, [params]); const pathPattern = useMemo(() => `/:${Object.keys(params).join('/:')}`, [params]); return ( ); };