-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Docs addon is not showing story code (No code available) unless you provide an unused variable into the function parameters #13362
Comments
Hey, Any updates on this one? We are seeing it too. Anyone know where to start/know roughly where the bug might be? Tom |
I'd try removing the storysource addon first since there are bad interactions between that and docs addon. The behavior of the
|
@shilman's idea of turning off the |
I am reading the content from read me file to create the doc. Is there any way to show the code with this approach? |
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Seeing this with a freshly bootstrapped react implementation using CSF 2.0 and storybook 6.4. Code is only available if i supply unused args param or if i use CSF 3.0
"No code available" (CSF 2.0)
Code shows properly (CSF 2.0)
Code shows properly (CSF 3.0)
|
@skylarmb do you have a "no code available" reproduction i can look at? |
@shilman I just created a fresh project so you can look at it. Setup: Step 2: Step 3: Resulting on following Docs with "no code available" for the story with no props on it: |
@andrebnassis thanks for the reproduction! i traced it down and it looks like there was an unintentional breaking change in please try upgrading prettier when they release their next update! |
Thanks @shilman! It works! I just want to check a tiny behavior (I don't know if it is expected or not). When the story has no props, the code generated includes the arrow function on it. Is it correct? I would expect in both cases that the code generated would shows me only the code itself (without the arrow function). |
@andrebnassis that's the intended behavior. you can read more about it here: https://storybook.js.org/docs/react/writing-docs/doc-blocks#source |
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! |
Had the same issue: In my case it got resolved by updating storybook & addons to the latest version (6.4.19). |
Tried to update storybook & addons to (6.4.19). This issue is still reproduced for me. However, adding an unused argument to the story function works properly. |
I can replicate this behavior @denyskorolkov described on 6.5.9, but I really wanted a global solution 😅 EDIT: |
We're on:
We provide Storybooks for both web components and React (the React components are a light wrapper around the web components). In the web component Storybook things work fine, but in the React Storybook we still see No code available unless we pass the unused argument to the |
It appears that for the React Storybook adding |
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
I'm using Storybook 7.6.4, and this errors occurs after switching the compiler from Babel to SWC. Perhaps there's a bug with SWC in detecting the source code of stories?
This answer works for me. To supplement a bit, place this code in export default {
parameters: {
docs: { source: { type: 'dynamic' },
},
} Here's the documentation for the |
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Due to a storybook bug, we need to add args to the story parameters in order to show the source. (storybookjs/storybook#13362)
Describe the bug
The docs addon is showing the error
No code available
if you do not provide a variable into the story function, regardless if the variable is used or not.To Reproduce
Expected behavior
Both stories,
exampleOne
andexampleTwo
, should have the ability to view their story code form within the docs addon.Screenshots
Note how the first one does not have code available, whereas the second one does. See the code snippet of the stories from this screenshot.
Code snippets
Additional context
This was not an issue with version
6.0.27
.The text was updated successfully, but these errors were encountered: