Reactjs 实验语法&x27;jsx&x27;isn';t当前已启用(react故事书)
运行storybook时收到以下错误:Reactjs 实验语法&x27;jsx&x27;isn';t当前已启用(react故事书),reactjs,jsx,babeljs,storybook,Reactjs,Jsx,Babeljs,Storybook,运行storybook时收到以下错误: WARNING in ./src/stories/button.stories.tsx Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: /<path_to_project>/src/stories/button.stories.tsx: Support for the experimental syntax 'jsx' isn't
WARNING in ./src/stories/button.stories.tsx
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /<path_to_project>/src/stories/button.stories.tsx: Support for the experimental syntax 'jsx' isn't currently enabled (45:35):
43 | const onClick = () => console.log('clicked');
44 |
> 45 | stories.add(NAME, () => { return (<Button onClick={onClick}>Hello Button</Button> );})
| ^
46 |
Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.
at Parser._raise (/<path_to_project>/node_modules/@babel/parser/lib/index.js:766:17)
顺便说一下,我已经安装了storybook插件jsx
,并通过addons.js
注册了它
关于如何解决这个问题有什么建议吗?#Chen你有什么解决方案吗?@Chen你有什么解决方案吗,我面临着角度+快照+玩笑的问题。抱歉,但还没有(必须转移到其他功能)-这只是一个附带项目,我会继续讨论。如果找到一个解决方案将更新#Chen你对此有什么解决方案吗?@Chen你有什么解决方案吗,我面临的问题是角度+快照+玩笑。对不起,但还没有(必须转移到其他功能)-这只是一个附带项目,我将返回。如果找到解决方案,将更新
{
"presets": [
[
"@babel/preset-env"
],
[
"@babel/preset-react"
],
[
"@babel/typescript"
]
],
}