Skip to content

[Feature]: Have the possibility to know if there is a route before. #9301

Closed as not planned
@ghost

Description

What is the new or updated feature that you are suggesting?

I suggest add a property or a method in useLocation() that should know about if there is a route before the actual route in my webpage.

Before v6.4.0 developers could know if there is a route before the actual with window.history.state.idx but in v6.4.0 this property isn't available.

Example: https://codesandbox.io/s/react-router-issue-9265-forked-h5s1yq

If you put react-router-dom 6.3.0 and you refresh the navigator of codesandbox you will see idx.
If you put react-router-dom 6.4.0 and you refresh the navigator of codesandbox you will see null.

Why should this feature be included?

I think that this is too useful to know when you can go back and not eject the user from your website if they just entered and click on a back button. If you know that the just entered on your page and you don't have a previous route you can go to a general route.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions