How does revalidateTag really works?
Answered
Korat posted this in #help-forum
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 ?
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
4 Replies
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
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
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
happy to help