Skip to content

Commit

Permalink
fix: ensure that privacy shield is always rendered in SSR to avoid hy…
Browse files Browse the repository at this point in the history
…dration issues
  • Loading branch information
axe312ger committed Feb 26, 2024
1 parent e2b0220 commit 49efbfe
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/core/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { Dispatch, SetStateAction, useContext } from 'react'
import React, {
Dispatch,
SetStateAction,
useContext,
useEffect,
useState,
} from 'react'
import { Location } from 'history'
import {
FallbackComponentProps,
Expand Down Expand Up @@ -78,10 +84,13 @@ export const PrivacyShield: React.FC<PrivacyShieldProps> = ({
children,
...props
}) => {
const [isSSR, setIsSSR] = useState(true)
const [decision] = useDecision(id)
const DefaultFallbackComponent = useFallbackComponent()

if (decision) {
useEffect(() => setIsSSR(false))

if (!isSSR && decision) {
return <React.Fragment>{children}</React.Fragment>
}

Expand Down

0 comments on commit 49efbfe

Please sign in to comment.