5

In React Router v5, we could provide a 404 response code in this way :

<Route path="*" component={NoMatch} status={404}/>

But how can we do it with React Router v6?

1
  • The react-router-dom v5 Route components don't have a status prop, and neither do the v6 Route components. Can you clarify the use case? How was this status prop being used previously? Can you update your question with an example? Commented Dec 8, 2021 at 6:51

1 Answer 1

3

The react-router-dom v5 Route components don't have a status prop, and neither do the v6 Route components. If this is simply passing the status prop through to the routed component then in RRDv6 you can pass it directly to the NoMatch component as a prop.

<Route
  path="*"
  element={<NoMatch status={404} />}
/>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.