-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
[6.0] Cannot add an args enhancer to the store after a story has been added. #327
Comments
As a note, patching these errors out and replacing with a "return;" I notice no issues with storybook. |
Hey @kyle-ssg thanks for reporting this issue. I think it's probably an incompatibility issue with 6.4.
your addons version is resolving to 6.4, currently 6.4 is not yet supported please use After you try it let me know and if it didn't work then I'm happy to debug further. |
I'm getting the same error when editing stories. I'm using
|
@ainsleyrutterford could you provide a public repository with a reproduction of the problem so I can debug it? |
Ah, the project I'm working on is private. I'll see if I can start a new project and reproduce the error. |
Same issue here. |
@levino a reproduction would be really great if possible 🙏 |
The amount of work to make a reproduction example is quite high. I will keep it in mind. The errors occur when one changes some code somewhere and then the app gets a refresh of the new code. I guess the configuration is run again, even though it should not have been. |
The problem is that without a reproduction its a lot of work for me to maybe succeed at reproducing an issue. I will try soon though, just need to find the time. |
I have reproduced the issue here https://github.com/patrikniebur/storybook-react-native-error But if I export the storybook UI as a default from the same file the issue disappears. My specific reason to try to render the StorybookUI inside of the component and not as the root component is embedding it into the app as one of the hidden routes. |
@patrikniebur thanks for the repro 🙏 I'll take a look tonight and see what I can find |
@patrikniebur be careful with your dependencies
these should be either a fixed version at 6.3.13 or |
With the reproduction I'm able to reproduce this. I'm working on finding the cause, thanks again for the reproduction @patrikniebur! |
like @patrikniebur mentioned it seems like you can avoid this by exporting the storybookUI directly like
instead of
So for now you can use that as a workaround. Still investigating. |
I'm thinking that I'll release a temporary fix for this whilst I figure out the root cause. It shouldn't require user changes though. Will update once its live. |
I am getting the same error while adding more than 1 stories file inside components |
Also this line gets automatically added in my storybook.requires.js file which throws this error: |
@samgalaxycard seems like you might be missing a dependency or some configuration. I have the temporary fix ready for this, just need to find time to release it (maybe tomorrow). Seems like there is a deeper issue though. A lot of changes are coming soon that would make this easier to solve. |
@kyle-ssg @samgalaxycard @patrikniebur I've published a temporary fix in 6.0.1-beta.6, could you try updating and running the sb-rn-get-stories command to update your requires file. |
@patrikniebur you need to run the script to update the requires file I tested on the same example and it works. |
Right, sorry I forgot about that part! Thanks for the fix, that's going to help a lot at my work! |
@patrikniebur by hot reload do you mean that it always full refreshes instead of doing a fast refresh? That specifically is a known bug with an issue and PR already #11 #30 The only issue is the pr with a fix seems to break storiesOf which is already deprecated however I'm not sure I want to commit to fully removing it. It's a complicated issue but its on the list of things to resolve. |
I mean no refresh at all. But I assume that's because of the same error that is being hidden now. Anyway editing component works fine with hot reload so I'm happy. Thanks again! |
@patrikniebur interesting, I'm not sure why that would happen. I'll definitely have to revisit hot reloading. |
I'm pretty sure it used to refresh correctly when editing a component before the fix. It was blowing up when editing a story. Now it swallows the error, so it appears that the underlying issue is still there. |
@tyom used to when? Catching the error is a workaround but it wouldn't be the thing that breaks reloading. Also if you see prior comments if you change the way you export the storybook ui then it should not even error and maybe would hot reload. Need to test this. |
@dannyhw I believe it used to refresh correctly when editing components prior to the latest fix in #351. However, when editing stories the refresh failed with the originally reported error. Now it says that the view has been refreshed without any changes. Editing the component works a treat though. It would be great if it refreshed correctly when editing a story as well. In addition, I have a global decorator and when editing the story (where refresh is reported but ignored) I'm getting a duplicate decorator warning. I wonder if it's related. |
@tyom yes I believe the code in preview is getting executed on every hot reload which shouldn't be the case unless that file changes. I've got some ideas on how to potentially fix that but I'm not an expert on hot reloading so it might take a lot of trial and error 😅 . If anyone can help that would be much appreciated, otherwise I'll explore some potential solutions as soon as I have an evening or weekend free. |
Just as an update: This is still very broken for me / us. Basically we have to reload the whole app every time we change some code. This is not the case for the real app. There all updates get streamed and applied. We also load the storybook on demand like so: import React, { useState, useEffect } from 'react'
import { DevSettings } from 'react-native'
import { loadString, saveString } from '~storage'
/**
* Toggle Storybook mode, in __DEV__ mode only.
*
* In non-__DEV__ mode, or when Storybook isn't toggled on,
* renders its children.
*
* The mode flag is persisted in async storage, which means it
* persists across reloads/restarts - this is handy when developing
* new components in Storybook.
*/
export function ToggleStorybook(props: any) {
const [showStorybook, setShowStorybook] = useState(false)
const [StorybookUIRoot, setStorybookUIRoot] = useState<React.FC>(
null as unknown as React.FC
)
useEffect(() => {
if (__DEV__ && DevSettings) {
// Load the setting from storage if it's there
loadString('devStorybook').then((storedSetting) => {
// Set the initial value
setShowStorybook(storedSetting === 'on')
// Add our toggle command to the menu
DevSettings.addMenuItem('Toggle Storybook', () => {
setShowStorybook((show) => {
// On toggle, flip the current value
show = !show
// Write it back to storage
saveString('devStorybook', show ? 'on' : 'off')
// Return it to change the local state
return show
})
})
// Add these lines line to re-enable storybook
// Load the storybook UI once
setStorybookUIRoot(
// eslint-disable-next-line @typescript-eslint/no-var-requires
() => require('../.storybook/Storybook').StorybookUIRoot
)
})
}
}, [])
if (showStorybook) {
return StorybookUIRoot ? <StorybookUIRoot /> : null
} else {
return props.children
}
} |
@levino hey sorry that you're still experiencing issues. I can see that you have an interesting way of loading storybook. What is the reason to use a state variable like this? Why not just require inline like:
Though I guess you got this from the ignite boilerplate right? Anyway, I can have a look at this again and I'll get back to you. |
This enables us to just toggle the storybook on and off via the dev menu in react native. Found this somewhere on the internet. If you want I can try to find the source. It works pretty well but for the update functionality. |
@levino ok but have you tried removing this stuff too see if it might be the cause of the hot reloading not working? If you directly export storybookui for example does your storybook reload properly? |
Just a ping back: I am not able to reproduce reliably. It happens currently with either import - sometimes :( I will further investigate and come back to this. |
I think this will be resolved atleast partly in #384 which I will hopefully be merging soon. |
Our issue was resolved by not using the |
This should be resolved in v6.5.6 already and in v7 this will work quite differently so I'm closing this. Let me know if you want to reopen. |
@dannyhw I am using v7 and unfortunately still having this issue. Specifically I am getting |
@arekkubaczkowski please specify which version your are on because this should be resolved. Make sure you are on the latest version for all related packages. |
@dannyhw I am on the latest version 7.6.15 |
I've just noticed that there were two releases lately and one of them fixes hot reloading 😅 let me check |
@arekkubaczkowski the latest version is 7.6.17 and it has a hot reloading fix |
make sure to regenerate the requires file as the fix is in the generated file. |
works like a charm! thanks a lot! |
Describe the bug
Whenever I edit a story I see the following error.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I can edit/add stories without errors
Screenshots
Code snippets
If applicable, add code samples to help explain your problem.
System:
Please paste the results of
npx -p @storybook/cli@next sb info
here.Additional context
I'm following the exact same code as in the native example in this repo with a couple of basic stories e.g.
The text was updated successfully, but these errors were encountered: