Detect URL change

Hi,

I would like to trigger a function on each URL change. Basically, on the state.router.link change.

What is the best way to achieve this in Frontity? Is there any preferred or native Frontity way?

Thanks.

When the url changes, state.source.data changes. You can take advantage of useEffect for this. Something like:

useEffect(() => {
  //Do something
}, [state.source.data])

You can place that in the index file of your components folder or in any other file where you are connected to state. It just depends on what you want to do.

Hope that helps.

Thank you for the answer. Yes, that’s what I did at the end.