Story-specific handler / request persisting after switching stories
See original GitHub issueHi there! Thanks for the add-on!
I’m running into a problem with a story that demos a loading state:
- The Loading story applies a handler with
ctx.delay('infinite')
. This story works great!- Specifically, this is a graphql handler for a request from Apollo Client.
- But when I load that story and then switch to another story in the same file, that second story also appears as loading forever. The pending request from the first story remains in the network tab, and no new request appears from the second story.
Any help debugging / solving this would be appreciated! Please let me know if additional info would be helpful.
It’s a bit hard to debug this / pinpoint what part of the stack may be responsible for not ending the pending request and initiating a new one when switching from the Loading story to the next one. Apologies if I’m barking up the wrong tree.
In the meanwhile, since refreshing the browser tab on the second (non-loading) story allows that story to load correctly, I’ve worked around this by using a decorator that reloads the iframe when leaving the Loading story. This is the only workaround I’ve found that helps.
// Yuck...
Loading.decorators = [
(Story) => {
useEffect(() => {
return () => window.location.reload();
}, []);
return <Story />;
},
];
Issue Analytics
- State:
- Created a year ago
- Reactions:14
- Comments:16
Top Results From Across the Web
Using Storybook and Mock Service Worker for mocked API ...
Mock Service Worker uses a worker script that enables requests ... For that, you can override request handlers on a per-story basis.
Read more >README.md · branch/default · Games / harlowe - Projects
Toolbar: Fixed a bug where the status of the "Coding tooltips" setting wouldn't persist after closing and reopening the passage editor.
Read more >How do you 'wiki' a string into a variable? (Sugarcube 2.21.0)
Hi. After some searching, I'm somewhat surprised that I haven't been able to find an elegant solution. What .
Read more >@storybook/react-native-server | Yarn - Package Manager
... knob renders a switch which lets you toggle a value between true or false // you call ... Storyshots: Support story-specific options...
Read more >An Authoring Framework for Interactive Narrative with Virtual ...
Discussion – The Problems of Application Design of Interactive Narrative . ... used to kill the king, when killing the king would change...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having this exact same issue - and it was related to when I started specifically passing in multiple mocks to the msw handler. I still don’t know what’s causing the issue, but thanks for your workaround.
Example of what caused it:
I think if we had some way of resetting handlers like we can in unit tests (with
server.resetHandlers()
), that might help us make sure the story uses the correct handler.