stack_overflow_nextjs14 icon indicating copy to clipboard operation
stack_overflow_nextjs14 copied to clipboard

Correction of Hydration Error in UserCard.tsx

Open sofiane-abou-abderrahim opened this issue 1 year ago • 1 comments

Let's take a look at our current code in components\shared\RenderTag.tsx: The RenderTag component is within a Link component and contains a Link component itself (Link wrapped inside another Link).

Now imagine trying to navigate to /etiquettes/${_id} and we end up in /profile/${user.clerkId}? That would be a problem. This is what's causing the hydration error.

If we want to fix this problem, we can remove the global Link component in the UserCard and wrap each of the divs, Images, and other components in a Link component, but not the RenderTag. This way we can ensure the hydration error does not happen.

sofiane-abou-abderrahim avatar Jul 28 '24 18:07 sofiane-abou-abderrahim