-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Addon-docs: Error: Evaluation failed: TypeError: Cannot convert a Symbol value to a string #11554
Comments
As a workaround you can set the |
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! |
NOTE: this is needed to put a |
@davidmenendez yes here is a babel plugin I added which works. You might have to adjust the replace functions with something that works better for your code: const template = require('@babel/template')
/**
* Adding this babel transformer supports the src code view with Suspense
* Until this issue is resolved, we have to add the src code docs ourselves:
* https://github.com/storybookjs/storybook/issues/11554
* The approach is to grab the src code for the entire file, and then strip out unecessary things
* like large file header helpers that storybook injects so we only show the essentials.
*/
module.exports = () => {
return {
visitor: {
Program(path, state) {
if (state.file.opts.filename.endsWith('.stories.tsx')) {
const srcCode = path.hub.file.code
.trim()
.replace(
/(.*((__(STORY|LOCATIONS_MAP)__)|(\/\/)|(\/\*)|(@storybook\/react)|(Template\.parameters =))|(Template\.storyName)).*/g,
''
)
.replace(/.*React\.Suspense.*\n/gm, '')
.replace(/export default.*Meta/s, '')
.replace(/\n\s*\n/g, '\n\n')
path.node.body.push(
template.default.ast(`
Template.parameters = {
...Template.parameters,
docs: {
source: {
code: \`${srcCode}\`
}
}
};`)
)
}
}
}
}
} In your module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-essentials'],
babel: async config => {
return {
...config,
plugins: [
...config.plugins,
path.resolve(__dirname, './babel-docs-plugin.js')
]
}
}, Here is a working lazy loaded component: |
I saw this error after upgrading to 6.4. It worked fine previously. I created an example repository for this. Is this actually Storybook problem or (Note: This workaround helps.) |
I'm still running into this issue over 2 years later 😞 I wanted to add a But getting the same error:
The workaround works for individual components. However it would be better if there was a "global" solution. I'm now having to go through all of our stories to:
x100 for all our of storybook components that rely on Suspense after upgrading. Does anyone know of a way to solve this problem at the storybook level instead of individual stories? in |
Submitted a PR here: #19004 |
Yo-ho-ho!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-alpha.46 containing PR #19004 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
This issue still exists using 7.0.0-alpha.48
gives the error
|
Maybe we need to find a way let
|
Handled by PR #19785 |
Hello, the PR #19785 has not been merged and this is still an issue. Using i18next in a global decorator is a common use case where the current issue occurs. Any plans to fix this? |
Issue persists in 7.0.0-beta.64 |
I am seeing this error using Storybook @shilman Can we re-open this issue? I see the PR mentioned above is still open. |
I am also seeing this issue in SB7 + React. |
Here's another workaround const ReactSuspense = ({ children }: { children: React.ReactNode }) => <React.Suspense>{children}</React.Suspense>;
export function withSuspense<TFramework extends AnyFramework = AnyFramework, TArgs = Args>(
story: PartialStoryFn<TFramework, TArgs>,
ctx: StoryContext<TFramework, TArgs>,
) {
return (
<ReactSuspense>
<>{story(ctx)}</>
</ReactSuspense>
);
} |
I noticed this issue is happening only when there are arguments in a story. For example, this will throw the error
But without "args", it work flawlessly:
|
This is still an issue in 7.6.16. Using a |
Describe the bug
The error
Error: Evaluation failed: TypeError: Cannot convert a Symbol value to a string
is thrown at runtime for a story under the cirucmenstance described below.To Reproduce
Steps to reproduce the behavior:
Expected behavior
It should not throw this error
Using storybook v6.0-rc3
Traced it down that the error originates here: https://github.com/algolia/react-element-to-jsx-string/blob/c4908bbb52e58e104c9d42d1ceaff80d53fd4bdf/src/formatter/formatReactElementNode.js#L122
The
react-element-to-jsx-string
package is a dependency is a dependency of the docs addon.While I dont have the time to build a repro case right now, I think it should be fairly easy to do with the information provided. Hope this helps. Best regards.
The text was updated successfully, but these errors were encountered: