Revalidate session and refresh layout component.
Answered
Northeast Congo Lion posted this in #help-forum
Northeast Congo LionOP
I have this code that you can feel free to criticize and may be fix if there is some issues. I'm trying to refetch the session for the navigation and header to update on the client but
revalidatePath(/dashboard) doesn't seem to work. I've also tried router.refresh() after the submission on the form but it does nothing. Anyone have an idea how to fix this issue?Answered by Northeast Congo Lion
I fixed it with
update() from the useSession() hook. It's a bit of stretch but it's working.22 Replies
try revalidatePath(/dashboard, 'layout')
Northeast Congo LionOP
it's still not working, gave me hope tho. Thanks
Wait so did you just do revalidatePath?
Because that's just gonna update the next time someone loads the page
Your gonna have to do both revalidatePath and a router.refreeh()
So on submit or whatever your trying to do, first revalidatePath then router.refresh()
Northeast Congo LionOP
No, I have the router refresh at the same time. Is this correct?
Northeast Congo LionOP
this is the server action I'm calling in the form
Both of the codeblocks don't match...
revalidatePath dosent have a second argument.. lemme check one second
Oh wow it does
Never had to use one before
Northeast Congo LionOP
yeah it does
I'm also shocked when @Ray mentioned it
Honestly don't see any issue with your code, make sure the page is correct, also try removing the second arg if it does fix
Northeast Congo LionOP
I'll find more ways to fix this. Thanks!
Northeast Congo LionOP
I fixed it with
update() from the useSession() hook. It's a bit of stretch but it's working.Answer