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

[knobs] Knobs don't appear on refresh when a decorator includes a suspense boundary #10

Open
andyrichardson opened this issue Nov 16, 2020 · 6 comments

Comments

@andyrichardson
Copy link

Describe the bug

When hittin

Note: May also apply to stories with suspense boundaries. Not tested.

To Reproduce

Consider the following application code

const Child = lazy(() => import("./Child"));

export const SomeComponent = ({ children }) => {
  return (
    <Suspense fallback={null}>
      <Child>
        {children}
      </Child>
    </Suspense>
  )
};

Consider the following decorator

const lazyDecorator = (Story, context) => {
  const someknob = Select("Something", ["A", "B"], "A");

  return (
    <SomeComponent>
      <Story {...context} />
    </SomeComponent>
  )
};

addDecorator(lazyDecorator);

Expected behavior

A decorator with a suspense boundary has no impact on how knobs work.

Screenshots

Kapture 2020-11-16 at 13 18 08

System

6.1.0-rc.3

@shilman
Copy link
Member

shilman commented Nov 16, 2020

FYI, we’ve released addon-controls in Storybook 6.0. Controls are portable, auto-generated knobs that are intended to replace addon-knobs long term.

Please upgrade and try them out today!

@andyrichardson
Copy link
Author

Hey @shilman, thanks for the suggestion!

Unfortunately controls can't be used because they can't be declared by decorators (#12836, storybookjs/storybook#11984)

@stale
Copy link

stale bot commented Dec 25, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@shilman
Copy link
Member

shilman commented Mar 2, 2021

@andyrichardson sorry for the slow reply. what's the use case for adding controls via decorator?

@andyrichardson
Copy link
Author

what's the use case for adding controls via decorator?

@shilman no worries!

Any application-wide context (e.g. language, region)

@shilman
Copy link
Member

shilman commented Mar 2, 2021

Have you looked at toolbars/globals for that?

https://storybook.js.org/docs/react/essentials/toolbars-and-globals

It's the controls/args analog for global variables. We'll probably be building more on top of that in the future (e.g. a way to show global controls side by side with story controls in the addon panel instead of only on the toolbar). But data-wise, it's the recommended way forward for this kind of stuff. And if it doesn't quite fit your use case, I'd love to discuss why and figure out how to make it work.

@shilman shilman transferred this issue from storybookjs/storybook May 10, 2021
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

2 participants