You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If in the story source file you use a method call with following definition xyz.add(arg1, arg2) it seems that storybook will use the value of the arg1 and inject it to it's generated code and throws following warning and breaks the story.
The method does not have to do anything with storybook and the method call is empty.
index.js:53 Unexpected error: ReferenceError: {arg1} is not defined.
{arg1} will be the value of the arg1.
In the generated main.XYZ.bundle.js following lines will be generated which are wrong (See screenshot):
It seems that storybook somehow parses the source and uses some sort of parsing and if it finds the .add method call it will use this as an indicator to add a specific story which in this case and any other case where the call looks like XYZ.add('…', '…') which leads to a warning and the story won't work anymore.
To Reproduce
Steps to reproduce the behavior:
Install a vanilla HTML storybook
Create `src/includes.js' file and add the content from below
Import includes file in stories/1-Button.stories.js: import { problem } from '../src/include'
Add following line after the import problem.add('thiswillgetinjected', null) // won't work
Run storybook and see warning in console (Plus the story won't be available)
problem.add('thiswillgetinjected')// will workproblem.add('thiswillgetinjected',null)// won't workproblem.add('thiswillgetinjected',{})// won't workproblem.add('thiswillgetinjected',{},{})// won't work
Watch out: Ensure that you do not export a story with the value in the add method call then it will work.
Happened to me and cost me some hours until I figured it out why some calls worked and some did not. :)
Expected behavior
There should not be any interference with storybook if you call a method named add and has no side effects inside the method call.
Screenshots
Code snippets
src/include.js
exportconstproblem={add: (a,b)=>{},}exportdefault{
problem
}
Describe the bug
If in the story source file you use a method call with following definition
xyz.add(arg1, arg2)
it seems that storybook will use the value of the arg1 and inject it to it's generated code and throws following warning and breaks the story.The method does not have to do anything with storybook and the method call is empty.
{arg1} will be the value of the arg1.
In the generated
main.XYZ.bundle.js
following lines will be generated which are wrong (See screenshot):It seems that storybook somehow parses the source and uses some sort of parsing and if it finds the .add method call it will use this as an indicator to add a specific story which in this case and any other case where the call looks like
XYZ.add('…', '…')
which leads to a warning and the story won't work anymore.To Reproduce
Steps to reproduce the behavior:
stories/1-Button.stories.js
:import { problem } from '../src/include'
problem.add('thiswillgetinjected', null) // won't work
Watch out: Ensure that you do not export a story with the value in the add method call then it will work.
Happened to me and cost me some hours until I figured it out why some calls worked and some did not. :)
Expected behavior
There should not be any interference with storybook if you call a method named
add
and has no side effects inside the method call.Screenshots
Code snippets
src/include.js
System
Environment Info:
System:
OS: macOS 10.15.5
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 14.5.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.5 - /usr/local/bin/npm
Browsers:
Chrome: 86.0.4240.193
Firefox: 81.0.1
Safari: 13.1.1
npmPackages:
@storybook/addon-actions: ^6.0.28 => 6.0.28
@storybook/addon-essentials: ^6.0.28 => 6.0.28
@storybook/addon-links: ^6.0.28 => 6.0.28
@storybook/html: ^6.0.28 => 6.0.28
The text was updated successfully, but these errors were encountered: