fix: react hook can't be used conditionally (#10439)

This commit is contained in:
Udit Takkar
2023-08-02 12:22:44 +05:30
committed by GitHub
parent e44a07b67c
commit 4ca9138e01
@@ -121,11 +121,7 @@ const LayoutToggle = ({
const isEmbed = typeof window !== "undefined" && window?.isEmbed?.();
const { t } = useLocale();
// We don't want to show the layout toggle in embed mode as of now as it doesn't look rightly placed when embedded.
// There is a Embed API to control the layout toggle from outside of the iframe.
if (isEmbed) {
return null;
}
const layoutOptions = useMemo(() => {
return [
{
@@ -146,5 +142,11 @@ const LayoutToggle = ({
].filter((layout) => enabledLayouts?.includes(layout.value as BookerLayouts));
}, [t, enabledLayouts]);
// We don't want to show the layout toggle in embed mode as of now as it doesn't look rightly placed when embedded.
// There is a Embed API to control the layout toggle from outside of the iframe.
if (isEmbed) {
return null;
}
return <ToggleGroup onValueChange={onLayoutToggle} defaultValue={layout} options={layoutOptions} />;
};