From 9facfd4583bb36d297a41331bfe1b0bec6d0c6b2 Mon Sep 17 00:00:00 2001 From: Felix Habib Date: Mon, 25 Nov 2024 14:21:39 +1100 Subject: [PATCH] add client check --- .../components/MenuRenderer/MenuRenderer.tsx | 109 ++++++++++-------- 1 file changed, 58 insertions(+), 51 deletions(-) diff --git a/packages/braid-design-system/src/lib/components/MenuRenderer/MenuRenderer.tsx b/packages/braid-design-system/src/lib/components/MenuRenderer/MenuRenderer.tsx index 0f92b1ae17b..a9be682bca9 100644 --- a/packages/braid-design-system/src/lib/components/MenuRenderer/MenuRenderer.tsx +++ b/packages/braid-design-system/src/lib/components/MenuRenderer/MenuRenderer.tsx @@ -386,6 +386,11 @@ export function Menu({ triggerPosition, }: MenuProps) { let dividerCount = 0; + const [isClient, setIsClient] = React.useState(false); + + React.useEffect(() => { + setIsClient(true); + }, []); const inlineVars = triggerPosition && @@ -395,59 +400,61 @@ export function Menu({ }); return ( - - - + isClient && ( + + - {Children.map(children, (item, i) => { - if (isDivider(item)) { - dividerCount++; - return item; - } - const menuItemIndex = i - dividerCount; - return ( - - {item} - - ); - })} + + {Children.map(children, (item, i) => { + if (isDivider(item)) { + dividerCount++; + return item; + } + const menuItemIndex = i - dividerCount; + return ( + + {item} + + ); + })} + + - - - - + + + ) ); }