Repository navigation
Invalid hook call error when using addon Knobs "text" knob #17
Description
Activity
FYI, we’ve released
addon-controlsin Storybook 6.0. Controls are portable, auto-generated knobs that are intended to replaceaddon-knobslong term.Please upgrade and try them out today!
@shilman Noted! I didn't realise they were intended to replace
addon-knobslong term, I shall check them out, thanks@Sniffing even short term for many! 😉 controls is still missing a couple features from knobs, but it also adds a few big ones and is already better in many ways (simpler, probably more stable, maintained).
Pulled it down, gave it a try, most of the controls seem good, I still seem to be having the issue above when using
argTypesand supplyingtextexport default { argTypes: { text: { control: { type: 'text', }, }, }, title: 'Icon With Text', }; const template = (args) => <Icon {...args} />; export const Default = template.bind({}); Default.storyName = 'Default'; Default.args = { text: 'Some text', };I'm getting the same error as the comment above when attempting to use
Default.args = { text: 'Some Text' }. It seems likewebpack://storybook_ui_dll//Users/shilman/projects/baseline/storybook/node_modules/react-textarea-autosize/dist/react-textarea-autosize.browser.esm.js?is getting a different instance of React.I edited
node_modules/react/index.jsto includemodule.exports.__asa = 1at the end of the file and confirmed in one of my stories thatReact.__asa === 1.Then with the debugger I can see
react__WEBPACK_IMPORTED_MODULE_2__.__asaisundefinedand runningnpm ls reactconfirms I only have 1 react and the rest arededeuped.I haven't used webpack DLLs before. Is that DLL packaging its own copy of React that doesn't show up in my
node_modules? I don't know how to figure out where that code is coming from, the path listed is not from my machine.I think my problem was that I had several
@storybook/componentsthat couldn't be deduped. I had to remove@sambego/storybook-statebecause it uses@storybook/components@5.3.21, which I think is what prevented all my@storybook/components@6.0.21from being deduped. There may be a better way to do this next step, but I just uninstalled and reinstalled all@storybook/*packages at the same time and that deduped all my@storybook/components.npm uninstall @storybook/react @storybook/addons @storybook/addon-links @storybook/addon-knobs @storybook/addon-essentials @storybook/addon-centered @storybook/addon-actions npm install -D @storybook/react @storybook/addons @storybook/addon-links @storybook/addon-knobs @storybook/addon-essentials @storybook/addon-centered @storybook/addon-actions npm ls @storybook/componentsYeah, we have a problem when third party addons have not upgraded their dependencies across breaking changes (5.3.x => 6.0.x)
@ndelangen @tmeasday any thoughts on how we can make this easier for users?
@jonniebigodes any ideas about how we might document this? troubleshooting page?@shilman we don't have exactly a good place for this. As a short term solution we could use the FAQ page (workflows/faq.md) and add a new section addressing this issue. As this issue is addressed we can then move it to a better place.
Let me know if you're ok with it and we'll move from there.
@jonniebigodes that sounds like a great place. 💯
Ran into this today when bumping from 6.0.21 to 6.0.22.
I experimented with forking @sambego/storybook-state to update the Storybook versions, which then only showed 6.0.22 when running
npm ls @storybook/components, however that did not fix the invalid hook issue when running Storybook.We've got extensive uses of the text control from
@storybook/addon-knobs, as well as a whole lot of@sambego/storybook-state, so either migrating toaddon-controlsor removing@sambego/storybook-statearen't low-effort options for us. Are there any other ways in which we can resolve this?Are there expected changes with future versions of Storybook that might make it less sensitive to version mismatches? If so, I might pin our version for a while and wait for those updates.
@stevethatcodes Storybook uses webpack DLLS for performance and this causes lots of version issues, possibly including this one. We're planning on getting rid of them in 6.1: storybookjs/storybook#12637
@shilman Aha, thank you for that info, I think we'll pin to
6.0.21in the mean time then and await6.1before upgrading further.Sorry for not addressing this change sooner. I had to shift my attention to other documentation. I'm going to make a pull request addressing this. To give a bit more context when using third party addons with the Storybook 6.0. Regarding your issue @Sniffing this is something that might need a bit more context and information. Sorry for not providing a better response but we're in a bit of a pickle as it's a company code. Once the pull request is created i'll link this issue.
Sorry for not providing a better answer for you.
Stay safe.
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. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!


Describe the bug
Related to:
When using addon knobs, any use of the
textknob with causes the above error. Removing knobs of this type while keeping other types do not cause the errorTo Reproduce
"@storybook/addon-knobs": "^6.0.21",Company source code, so cannot link.
withKnobsdecoratortextExpected behavior
Story for component loads with knob
Code snippets
System: