Abraham
Abraham

Reputation: 15700

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

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

Upvotes: 1

Views: 469

Answers (1)

Abraham
Abraham

Reputation: 15700

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>}/>
    

Upvotes: 1

Related Questions