-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Ability to refresh (force rerender) of story #1736
Comments
This is really interesting! |
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. We do try to do some housekeeping every once in a while so inactive issues will get closed after 90 days. Thanks! |
I'll take a crack at it when I get a chance |
Also adds support for redux DevTools
Also adds support for redux DevTools in react/client
…#1736)-Ability-to-force-redender-a-story
…#1736)-Ability-to-force-redender-a-story
…#1736)-Ability-to-force-redender-a-story # Conflicts: # app/react/src/client/preview/render.js
…ender-a-story [WIP] (#1736) ability to force re-render a story
Released as 3.4.0-alpha.0 |
Is there any doc on how to use this/is this actually available? |
awesome! |
No. I'm going to support it there as part of #3555 (It's needed for knobs) |
How do I use this in Angular? Any examples? |
How do we use this with Ember? Is there support for that? |
For anyone trying to accomplish this in combination with a It's important that you specify a (input on how to get this working using the It's worth noting that a global variable should exist, f.e. counter which you update. Not the most elegant, but it works.
I'm using |
For anyone wondering how to use this feature in Angular you need to import the function:
... and then use it whenever you need. |
Working Solution Example (inside preview.js):
|
Hello, please does anyone have working solution of
with Storybook 7? This code works perfectly with sb6, but after upgrade it stopped work. Thank you |
Just coming from the future 2023, this function has been removed from storybook/react oin version 7
|
TEMP SOLUTION for Storybook7 function forceRerender() {
const buttons = window.parent.document.querySelectorAll('button[title]');
for (const button of buttons) {
if (button.getAttribute('title') === "Remount component") {
button.click();
return
}
}
} |
I think I have a related issue. I have some
This updates properly, but my component still has the previous class, if I click the button in the toolbar for a theme a second time it updates appropriately. |
It would be neat if addons could tell the Storybook API to refresh a given story. Using storybookAPI.selectStory() does nothing if the story is already selected.
This would be useful when a story wants to customize hot-reloading to maintain parts of its state, through e.g. a Redux store. This would support stories like this:
I've already written an addon (unpublished) which does this by selecting another (dummy) story and selecting back to the original story. It works, quite well, but requires a dummy story. This is obviously imperfect, and you still have to do hard reloads from time-to-time, but it comes close to the "regular" app workflow but I can isolate mocking my network stack to my stories, specifically.
The relevant "blocker" is in init_api.js#L48. I realize you wouldn't usually want to emit an event for the same story, but maybe there could be an escape hatch for an explicit re-render?
The text was updated successfully, but these errors were encountered: