Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react run on route change

import { useLocation } from 'react-router-dom'

function usePageViews() {
  let location = useLocation()

  useEffect(
    () => {
     // run code
    },
    [location]
  )
}
 
PREVIOUS NEXT
Tagged: #react #run #route #change
ADD COMMENT
Topic
Name
4+2 =