Replies: 1 comment 1 reply
-
Why do you need it in Redux? You could call useLocation in any component you nee dit, it's already a global state. Aside of that, adding it inside your router and using an effect to send them to Redux makes sense, you need to keep updating the location on your Redux store whenever the actual location from useLocation changes, it's the same as if you stored it in a useState, you would have to do: let location = useLocation()
let [state, setState] = useState(() => location)
useEffect(() => {
setState(location)
}, [location]) Which leads me to my first question, you could just use the useLocation directly instead of saving it in another place. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to put location data into redux state. But i cannot use like this

because useLocation must be inside of RouterProvider
so i suggest to put children in to use like this

Beta Was this translation helpful? Give feedback.
All reactions