From 6a5e2db8b888267ba4b24e19b6320ff04629bcd3 Mon Sep 17 00:00:00 2001 From: Marcos Moura Date: Wed, 7 Dec 2022 19:21:54 +0100 Subject: [PATCH] fix: avoid conditional hook call --- .../src/withCodeSandboxButton.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/storybook-addon-export-to-codesandbox/src/withCodeSandboxButton.ts b/storybook-addon-export-to-codesandbox/src/withCodeSandboxButton.ts index 170361e..29e6153 100644 --- a/storybook-addon-export-to-codesandbox/src/withCodeSandboxButton.ts +++ b/storybook-addon-export-to-codesandbox/src/withCodeSandboxButton.ts @@ -5,11 +5,11 @@ import { getDependencies } from './getDepdencies'; import type { PackageDependencies } from './getDepdencies'; export const withCodeSandboxButton: StoryWrapper = (StoryFn: StoryFunction, context: StoryContext) => { - if (context.viewMode === 'docs') { - useEffect(() => { + useEffect(() => { + if (context.viewMode === 'docs') { displayToolState(`#anchor--${context.id} .docs-story`, context); - }); - } + } + }, [context]); return StoryFn(context); };