Open TheCrether opened 3 days ago
Why do you need to memoize the view component? Note that React Router already takes care of not re-rendering the view even if the parent layout containing the <Outlet>
is re-rendered.
As a workaround, you could probably add a dummy component around the view and then exporting this component instead.
function RealView() {
return <span>Hello</span>
}
const RealMemo = memo(RealView);
export default function RealViewWrapper() {
return <RealMemo />
}
Describe the bug
When using React's
memo()
function to wrap a React component that is a route (a.tsx
file under the folderviews
) before exporting, an uncaught error gets thrown that is a bit confusing.Expected-behavior
I would expect for the routes still to be rendered fine since they do not have any props anyways.
Reproduction
This code should work:
This code does not work:
System Info