You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the comment at the sandbox when using Switch inside a nested route access to location.state from withRouter is overwritten. When not (use Fragment at the sandbox) then it works as expected.
Expected Behavior
When using Switch and I access location.state props from withRouter HOC I can see the state I have passed to the specific route.
Actual Behavior
When using Switch and I access location.state props from withRouter HOC the state not defined.
The text was updated successfully, but these errors were encountered:
npetridis
changed the title
Using <Switch /> makes access to location.state from withRouter HOC it is not defined.
Using <Switch /> makes location.state accessed from withRouter HOC to not be defined.
Oct 14, 2020
Switch sets the location prop on the child it selects to render. This isn't the correct way to set that state anyways. You should be setting it on the Link so it's saved in the history stack.
Version
In my environment: 4.3.1
In sandbox provided: 5.2.0
Test Case
https://codesandbox.io/s/react-router-forked-vd9kr?file=/index.js
Steps to reproduce
/test
pageExpected Behavior
When using Switch and I access location.state props from withRouter HOC I can see the state I have passed to the specific route.
Actual Behavior
When using Switch and I access location.state props from withRouter HOC the state not defined.
The text was updated successfully, but these errors were encountered: