react-router-dom index Type 'true' is not assignable to type 'false'.ts(2322)

Viewed 86

I am using React Router 6 with typescript and index prop for <Route> is not taking true or boolean values

<Routes>
    <Route index>
        <h1>Here</h1>
    </Route>
</Routes>

It shows the following error

1 Answers

To use index prop, you need to satisfy this

  • Should not have path prop

  • Should not have children but only an element prop

    <Route index element={<h1>Here</h1>}/>
    
Related