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

Controls reset when hot reloading #13394

Closed
florian-milky opened this issue Dec 7, 2020 · 5 comments
Closed

Controls reset when hot reloading #13394

florian-milky opened this issue Dec 7, 2020 · 5 comments

Comments

@florian-milky
Copy link

Describe the bug
When developing a component using a story and controls, everytime the code is saved, the story reloads with default control values.

To Reproduce
Steps to reproduce the behavior:

  1. create a story with controls
  2. run storybook locally
  3. change some control values
  4. update your component

Expected behavior
story should hot reload with same controls

Screenshots
N/A

Code snippets
N/A

System
Environment Info:

System:
OS: macOS 10.15.6
CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
Binaries:
Node: 14.13.1 - ~/.nvm/versions/node/v14.13.1/bin/node
npm: 6.14.8 - ~/.nvm/versions/node/v14.13.1/bin/npm
Browsers:
Chrome: 87.0.4280.88
Safari: 13.1.2
npmPackages:
@storybook/addon-actions: ^6.1.9 => 6.1.9
@storybook/addon-essentials: ^6.1.9 => 6.1.9
@storybook/addon-knobs: ^6.1.9 => 6.1.9
@storybook/addon-links: ^6.1.9 => 6.1.9
@storybook/addons: ^6.1.9 => 6.1.9
@storybook/react: ^6.1.9 => 6.1.9

Additional context
Add any other context about the problem here.

@tmeasday
Copy link
Member

Hi @florian-milky -- can you tell if your app is HMR (hot module reloading / fast refreshing without reloading the browser tab) or not?

I would be surprised if the args were being reset on HMR (in which case a reproduction would be useful). OTOH if your SB is reloading when you edit a component, you might want to investigate why, although I tend to think args shouldn't reset then either (we already store globals in session storage, we should store args there too I think).

@florian-milky
Copy link
Author

Thanks @tmeasday.
Yes I am using HMR. I will investigate if something is refreshing at a too high level, and I'll report back.

@florian-milky
Copy link
Author

I had to enable fast refresh.
Didn't think it wouldn't be added by default :)


  • You can set a FAST_REFRESH environment variable in your .env file:
FAST_REFRESH=true
  • Or you can set the following properties in your .storybook/main.js files:
module.exports = {
  reactOptions: {
    fastRefresh: true,
  }
};

@tmeasday
Copy link
Member

I still think we should retain control values if HMR isn't working 👍

@tmeasday
Copy link
Member

This will be fixed by #13803 and as such is probably subsumed by #12291

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

No branches or pull requests

3 participants