[Bug]: State is not preserved in a component tree when switching to render via custom <Routes location={location}>
prop
#11902
Labels
<Routes location={location}>
prop
#11902
What version of React Router are you using?
6.26.2
Steps to Reproduce
<Routes location={location}>
component that potentially receives a customlocation
prop, initiallynull
.location
prop value to change, changing it to the same current browser location.There's a test case provided in the pull request that proposes a fix to this issue (#11901). This test case shows in more detail how to reproduce.
This was originally reported in #9094 (comment)
Details
Expected Behavior
The tree of components under the rendered route should not be recreated by React. It should be preserved, and, if anything, just updated. But not re-mounted. A clear indication that it is working as expected is if any internal state inside this subtree is preserved, instead of being reset.
Actual Behavior
This tree of components is re-mounted, instead of just updated. Causing any internal state in this subtree to be reset / lost.
The text was updated successfully, but these errors were encountered: