addon-docs, unconsistent "showCode" behaviour (6.0.0-rc.14)
See original GitHub issueDescribe the bug Given 2 story functions implementing the same component, the rendered source code is not the same depending on the story function parameters (6.0.0-rc.14, typescript and react)
To Reproduce This is reproductible in an easy manner. In a *.stories.tsx, add these 2 functions :
export const SampleWithoutParams = () => {
return (<div>a</div>);
};
export const SampleWithParams = (args: Args, ctx: StoryContext) => {
return (<div>a</div>);
};
Then in the docs tab, click on “showCode” :
Expected behavior IMHO, the source code should be the same. I mean the first one eg :
() => {
return (<div>a</div>);
}
Seems that when there are params, source code is “interpreted”.
System:
Environment Info:
System:
OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
Binaries:
Node: 13.3.0 - ~/.nvm/versions/node/v13.3.0/bin/node
npm: 6.13.1 - ~/.nvm/versions/node/v13.3.0/bin/npm
Browsers:
Chrome: 84.0.4147.89
Firefox: 78.0.2
npmPackages:
@storybook/addon-actions: ^6.0.0-rc.14 => 6.0.0-rc.14
@storybook/addon-docs: ^6.0.0-rc.14 => 6.0.0-rc.14
@storybook/addon-jest: ^6.0.0-rc.14 => 6.0.0-rc.14
@storybook/addon-links: ^6.0.0-rc.14 => 6.0.0-rc.14
@storybook/addon-storysource: ^6.0.0-rc.14 => 6.0.0-rc.14
@storybook/addons: ^6.0.0-rc.14 => 6.0.0-rc.14
@storybook/preset-create-react-app: ^3.1.4 => 3.1.4
@storybook/react: ^6.0.0-rc.14 => 6.0.0-rc.14
Additional context Sorry if this is not a bug, I tried to search but did not found an issue about that.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top Results From Across the Web
@storybook/addon-storysource | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >storybook/addon-docs - npm
The addon-docs preset has a few configuration options that can be used to configure its babel/webpack loading behavior. Here's an example of how ......
Read more >storybookjs/storybook (Raised $170.00) - Issuehunt
[Bug]: Action Handler Returning Boolean Has Inconsistent Behaviour ... Addon-docs: 'show code' not displaying correct component name when using forwardRef ...
Read more >storybook/svelte: Versions - Openbase
Addon-docs : Use jsxOptions instead of mdxBabelOptions #20271 ... Angular: Add angular 14 sandbox template #19181; Storybook for Storybook ... 6.4.0-rc.6.
Read more >Storybook Addon-Docs don´t show Code Snipped
Are you using the MDX syntax to write your stories ? – Mteuahasan. Nov 14, 2019 at 14:00 · No Component Story Format...
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
This is still WIP and I’ll document it properly including the rationale once things are finalized. In a nutshell, there is a new parameter
docs.source.type
which can take on the values'auto' | 'code' | 'dynamic'
. Default is ‘auto’ which chooses ‘dynamic’ for args stories and ‘code’ for classic stories. You can force this to be ‘code’ globally to get the behavior you want. Away from keyboard for a few days but will be smoothing everything out here next week.Ah - I think all of my stories must have params, as mine always look like your second option, hence opening this issue: #11645…
Definitely would prefer if the actual source was used instead of just displaying the resulting DOM.