question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addon-docs, unconsistent "showCode" behaviour (6.0.0-rc.14)

See original GitHub issue

Describe 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” : Capture d’écran de 2020-07-24 09-37-27

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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
shilmancommented, Jul 24, 2020

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.

2reactions
redders6600commented, Jul 24, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found