1

How to grab hash location with onload

            <Redirect exact from="/:id" to="/user/1231231"/>
            <Route path="/user/:id" exact component={UserComponent}/>
1
  • How about creating separate component for handling redirections and concatenating query params via history.push? Commented Mar 18, 2020 at 17:37

1 Answer 1

1

I don't know what versions of packages you are using. But here basic example. Try to go ?profile=:id

https://codesandbox.io/s/react-router-stackoverflow-lchu9

gif

Sign up to request clarification or add additional context in comments.

2 Comments

It gives me this error TypeError: Cannot read property 'pathname' of undefined I have updated my question with my packages thank you
There is no reason why it should not work, you need to debug. Also consider that I am using different version of router than you. Look to docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.