Skip to content

fix (notifications): prevent hydration mismatch in notifications trigger#5

Open
dhaanisi wants to merge 1 commit intobaseforge-org:mainfrom
dhaanisi:fix/notifications-hydration
Open

fix (notifications): prevent hydration mismatch in notifications trigger#5
dhaanisi wants to merge 1 commit intobaseforge-org:mainfrom
dhaanisi:fix/notifications-hydration

Conversation

@dhaanisi
Copy link
Copy Markdown

Summary

This PR prevents a hydration mismatch in the notifications trigger component.

NotificationIconButton from @knocklabs/react can render different markup between the server and client (for example, theme-dependent classes like light/dark variants). When rendered during SSR, this can cause a React hydration warning in development.

Changes

  • Added a client mount guard using mounted state with useEffect to ensure the component renders only after the client has mounted.
  • Simplified render guards and avoided repeated keys() calls.
if (!mounted || !NEXT_PUBLIC_KNOCK_API_KEY) {
  return null;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant