0

If a user goes to a page that requires a context beyond what's on the url, I'd like to redirect them elsewhere. The use case is:

  • /todos/list - this page shows the user their list of todos. It contains links to:
  • /todos/edit?id=1 - this page allows the user to view/edit details about a particular todo.

If a user were to go directly to /todos/edit (with no id), I'd like to redirect them to /todos/list. I have tried doing this via navigate('list') conditionally in the constructor. This does update the browser url correctly, but it doesn't render the /todos/list page. Is this possible to do? Or is this not possible to do the para below?

I understand the more common url would be /todos/edit/1 so that reach router would handle my issue w/out me needing to deal with it. However, I'm just using this as an example of a piece of information required to render the page that isn't necessarily part of the the url path.

andersonbd1
  • 5,266
  • 14
  • 44
  • 62

1 Answers1

0

of course as soon as I type the question in stackoverflow, I find the answer is in the docs right in front of my face:

https://reach.tech/router/api/Redirect

andersonbd1
  • 5,266
  • 14
  • 44
  • 62