telejson: [Bug] name2.replace is not a function
Describe the bug
When navigating through stories, this error pops up.
The problem seems to come from
const Fn = new Function(`return function ${name2.replace(/[^a-zA-Z0-9$_]+/g, "")}(){}`)();
where name2 is actually { name : "string" }
Steps to reproduce the behavior
The following script seems to be enough for Storybook to throw errors.
class AbstractInput {}
const spec = [new AbstractInput("phone")];
export default {
title: "Example/Form",
args: {
spec
}
};
export const Default = {
render: () => document.createTextNode("Bar")
};
export const WithCustomInput = {
render: () => document.createTextNode("Foo")
};
The project where it fails can be found here
Expected behavior
The parsing should work
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 11
- Comments: 16 (4 by maintainers)
I found a fix in storybook, I’ll open a PR, and try to get this merged/patch asap.
This breaks Storybook on every hot-reload and makes development unworkable after updating to Storybook v7.1.0.
I’m on 7.2.1 and I still see the issue:
I still see this issue with
"storybook": "^7.3.2"I still get the
name2.replace is not a function...error with everything on the latest version.I’ll try and fix this today!
as a workaround, I locally replaced this line with
and so far it seems to work 😄
Same happening here, it happens when an instance of a class is passed to the
argsobject.To reproduce it, I had to edit the component code while displaying that same component from Storybook in the browser.