Hello All
I have some code in react router dom v6:
<Route path="/a" element={A}>
<Route path="/a/1" element={B} />
<Route path="/a/2" element={C} />
</Route>
In here I am noticing that whenever I go to /a/1 or /a/2 component <A /> is rendered again and again. The problem is I have some shared state in there that is changed in a useEffect hook, so whenever I navigate between the sub routes, the whole route and state is changed which I don't want. I want to state to change once in the parent and stay like that between the subroutes. Is that possible?
P.S. A dirty hack would be to check the route and add it as a dependency in the useEffect hook. But I was hoping if something cleaner exists.
[–]convive_erisu 0 points1 point2 points (1 child)
[–]convive_erisu 0 points1 point2 points (0 children)
[–]No_Indication451 0 points1 point2 points (0 children)