Next.js Discord

Discord Forum

How does revalidateTag really works?

Answered
Korat posted this in #help-forum
Open in Discord
Avatar
KoratOP
I wanted to know the steps nextjs takes when revalidateTag is called.

If I set a default value on a state from props which might change, does revalidateTag makes that client component start fresh (meaning it takes the new prop as default value) does it preserve the first default prop value ?
Answered by B33fb0n3
the revalidateTag will change everything that is different on your page. React would notice the change of the default value, but it already has a (the old) value. Because of this it won't change the value, but it will change the default value
View full answer

4 Replies

Avatar
the revalidateTag will change everything that is different on your page. React would notice the change of the default value, but it already has a (the old) value. Because of this it won't change the value, but it will change the default value
Answer
Avatar
KoratOP
Yeah, I noticed it last night because setting defaultValues on react-hook-form would not show the latest data after revalidateTag was triggered on an action.

In the other hand I could see the new data in console log, I reckoned this was a react thing because setting a default value on a state from props don’t change when that prop changes.

However, I needed to know if revalidateTag renders everything fresh
Thank you
Avatar
happy to help