Open stevegreco opened 1 month ago
Also facing the exact same issue, which appeared in version 8.3.0. For the moment, staying on 8.2.9 prevent the issue.
The same problem happens to me as well. Here is reproduction: chromatic preview, code
Facing the same issue, it started happening with 8.3.0
. It works fine till 8.2.9
. I have the pretty much the same story example as given in description.
Just notice this same issue today. Every story that has a useState is broken :(
Downgraded from 8.3.5 to 8.2.9 and useState works for me now.
I love the Empathy Backlog
name. Sending warm vibes to Storybook comrades.
A not so ideal work around is:
export function Story() {
return ComponentDecorator(Component);
}
A not so ideal work around is:
export function Story() { return ComponentDecorator(Component); }
Sometimes Context is needed.
@yannbf This issue is really complicated and in fundamental way, this was broken for quite some time.
The issue seemed to have been aggravated by a RSC decorator change.
Here is a PR that should fix that issue: https://github.com/storybookjs/storybook/pull/26243
There will still be a problem when a user write a chain of decerator like this itself:
withThemeByDataAttribute<ReactRenderer>({
themes: {
light: 'light',
dark: 'dark',
auto: 'auto',
},
defaultTheme: 'light',
attributeName: 'data-color-mode',
}),
// We have something like this decorator now by default in React since 8.3.0
// But you get the same error with a custom decorator, that doesn't use storyFn.
(Story) => {
return <Story />;
},
Or even a custom decorator that uses the storybook context in some way:
(storyFn) => {
useParameter("bla", {});
return storyFn();
},
(Story) => {
return <Story />;
},
This is a very weird issue. We are not yet at the bottom of this problem.
We might be able to prevent it with a custom applyDecorator, in a similar way that Vue has:
And add a (S) => decorator in between each other decorator in the stack. After some experimenting it seems that React doesn't loose its react state in this way.
Describe the bug
When attempting to use a custom
render
function to create a Story for a controlled component, I am getting the following error.This previously worked fine, so I am curious what changed.
My Story code is as follows. I am just trying to use a basic implementation of
useState
. The Story renders correctly, but as soon as I press theButton
, this error is displayed.From what I can tell, this is being caused by
@storybook/addon-themes
. You can see my setup in the reproduction.Reproduction link
https://stackblitz.com/edit/github-rjewa6?file=.storybook%2Fpreview.ts
Reproduction steps
System
Additional context
No response