Skip to content

Mutate revalidate with query params #505

Answered by sergiodxa
emulienfou asked this question in Q&A
Discussion options

You must be logged in to vote

What you should do is to pass the query to useSWR like this:

const [queryParams, setQueryParams] = useState("");
const { data } = useSWR(`/events?${queryParams`);

This way, every time queryParams change you will trigger a new render, and you don't need to call mutate.

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@gustavocd
Comment options

@ConsoleTVs
Comment options

@iamyoki
Comment options

Answer selected by emulienfou
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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