Im trying to upgrade to v6 of react router dom. The application works but I cant seem to get the testcases to work.
Before we had this wrapper for jest:
const render = (ui: React.FC, path: string, route: string): RenderResult => {
const history = createMemoryHistory({ initialEntries: [route] });
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false,
},
},
});
return {
...render(
<QueryClientProvider client={queryClient}>
<Router history={history}>
<Route path={path} component={ui} />
</Router>
</QueryClientProvider>,
),
};
};
After following the documentation for v6 I got the application to work and I updated the wrapper for jest to the following solution:
return {
...render(
<QueryClientProvider client={queryClient}>
<Router location={history.location} navigator={history}>
<Routes>
<Route path={path} element={ui} />
</Routes>
</Router>
</QueryClientProvider>,
),
};
This results in the following error:
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it.
Majority of the components in the project are function components. So getting this to work is kinda vital. :/