AI-powered
podcast player
Listen to all your favourite podcasts with AI-powered features
How to Make Sure That the Use State Hook Is Always in Sync With the Query Parameters
The use state hook that you created was always in sync with the query params. Was there some sort of a use effect that it was using to watch the query parameters or was there some other way that you were making sure that it stayed in sync at all times? Yeah, great question. We use the use effect to make sure that when the query parameters change, the state value changes. So this can happen when a user like goes back in history and then your query parameters might change as well.