remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
53.21k stars 10.32k forks source link

[Bug]: useEffect + useLocation not work in version 7... was in 6 #12361

Open passariello opened 1 day ago

passariello commented 1 day ago

What version of React Router are you using?

version 7

Steps to Reproduce

  const location = useLocation()

  useEffect(
    () => {
      console.log(location)
    }, [location]
 )

Expected Behavior

useEffect will be fired from location change. Work in 6 ... not in 7 It's a disaster!

Actual Behavior

no page change if location change. Make the route completely un-useful

timdorr commented 23 hours ago

This should work just fine. We need to see more context.

Can you provide a reproduction on Stack Blitz or a similar tool?