Skip to content
Discussion options

You must be logged in to vote

If you have persisted filters in localStorage, then the default value is set to that, so setting it to an empty array in the reset function is not going to match the default value, and therefore not clear it from the URL.

Instead, you should set the states you want to reset to null, which will:

  1. Clear it from the URL (as you want)
  2. Set the state to the default value (which may differ from an empty array if the user has persisted filters)

The issue with point n°2 is that the default value is closed over from the previous render, and so updating the local storage, even if done before updating the URL state, will still use a stale default value from the previous render. You'd have to:

  1. Reset…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by franky47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants