Prevent server functions to be called at render
Unanswered
Asian black bear posted this in #help-forum
Asian black bearOP
Howdy fellow developers
I'm using URL params to flow information between client & server components
For example this URL : localhost:3000/contrats/1202028227?modif=service allows to display a modal specific to the service modification. This modal calls a server function.
If I refresh the page I get lofically the following error
I want to know how to manage this and redirect to localhost:3000/contrats/1202028227 if a user arrives directly on this URL / does a refresh as this will cause server function to be called at render.
I don't want to used proposed solution in the error since this would mean pre fetching the data through the server function even if the user never goes on the modal
I'm using URL params to flow information between client & server components
For example this URL : localhost:3000/contrats/1202028227?modif=service allows to display a modal specific to the service modification. This modal calls a server function.
If I refresh the page I get lofically the following error
Error: Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead.I want to know how to manage this and redirect to localhost:3000/contrats/1202028227 if a user arrives directly on this URL / does a refresh as this will cause server function to be called at render.
I don't want to used proposed solution in the error since this would mean pre fetching the data through the server function even if the user never goes on the modal