Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storybook context already exists #50

Open
vytenis-sciukas-nfq opened this issue Feb 19, 2025 · 1 comment
Open

Storybook context already exists #50

vytenis-sciukas-nfq opened this issue Feb 19, 2025 · 1 comment

Comments

@vytenis-sciukas-nfq
Copy link

I get "Storybook context already exists" when I use nested components like

<twig:SomeParentComponent>
   <twig:SomeComponent>
   </twig:SomeComponent>
</twig:SomeParentComponent>

Symfony version is 6.4
With latest Storybook bundle

@vytenis-sciukas-nfq
Copy link
Author

Temporary solution for me is to fork and

    #src/Util/StorybookContextHelper.php
    public static function addStorybookContext(array &$variables, StorybookContext $context): void
    {
        if (true === self::hasStorybookContext($variables)) {
            throw new \InvalidArgumentException('Storybook context already exists.');
        }

        $variables[self::CONTEXT_KEY] = $context;
    }

remove exception throwing

#src/Util/StorybookContextHelper.php
public static function addStorybookContext(array &$variables, StorybookContext $context): void
    {
        if (true === self::hasStorybookContext($variables)) {
           return;
        }

        $variables[self::CONTEXT_KEY] = $context;
    }

do not know side effect of this, but it works for now solves a problem, and logically there is no need for context to be replaced for child elements, only parent element is important.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant