Closed
Description
What version of React Router are you using?
6.4.3
Steps to Reproduce
export default function MyPage()
{
return undefined;
}
const router = createBrowserRouter(createRoutesFromElements(
<>
<Route path="/" element={ <MyPage /> } />
</>
));
Expected Behavior
As of React 18, a component can return undefined
instead of null. See official PR and write-up.
At the moment, the TS typings for the Route
component in react-router do not accept passing an element that returns undefined
, only null.
Actual Behavior
Type 'undefined' is not assignable to type 'Element | null'.ts(2786)