Skip to content

Commit 7b7f3ef

Browse files
committed
Prevent initial callback to be called multiple time
1 parent eaa1cb3 commit 7b7f3ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/gdpr/ConsentBannerAndConsentManagement/ConsentBannerAndConsentManagement.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ export function createConsentBannerAndConsentManagement<
5050
consentModalButtonProps
5151
});
5252

53+
let onHydrated: (() => void) | undefined = () => {
54+
processConsentChanges({ "type": "no changes but trigger consent callbacks" });
55+
onHydrated = undefined;
56+
};
57+
5358
function ConsentBannerAndConsentManagement() {
5459
const [isHydrated, setIsHydrated] = useReducer(() => true, false);
5560

5661
useEffect(() => {
57-
processConsentChanges({ "type": "no changes but trigger consent callbacks" });
62+
onHydrated?.();
5863

5964
setIsHydrated();
6065
}, []);

0 commit comments

Comments
 (0)