Reactjs Storybook使用Docs加载项和.mdx文件引发意外的默认导出,但没有标题
我正在尝试在我的故事书中使用docs插件。我已将我的故事书配置如下:Reactjs Storybook使用Docs加载项和.mdx文件引发意外的默认导出,但没有标题,reactjs,storybook,Reactjs,Storybook,我正在尝试在我的故事书中使用docs插件。我已将我的故事书配置如下: module.exports = { stories: [ '../src/**/*.stories.([tj]sx|mdx)', '../docs/**/*.([tj]sx|mdx)' ], addons: [ '@storybook/preset-typescript', '@storybook/addon-actions/register', '@storybook
module.exports = {
stories: [
'../src/**/*.stories.([tj]sx|mdx)',
'../docs/**/*.([tj]sx|mdx)'
],
addons: [
'@storybook/preset-typescript',
'@storybook/addon-actions/register',
'@storybook/addon-storysource',
'@storybook/addon-docs'
],
webpackFinal: async config => {
config.module.rules.push({
test: /\.(ts|tsx)$/,
loader: require.resolve('babel-loader'),
options: {
presets: [['react-app', { flow: false, typescript: true }]],
},
});
config.resolve.extensions.push('.ts', '.tsx');
return config;
},
};
我创建了以下文件docs/welcome.mdx
:
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
<Meta title="Welcome" />
Test
从'@storybook/addon docs/blocks'导入{Meta,Story,Preview};
试验
故事书已成功生成,但显示任何组件的以下错误:
Unexpected default export without title: undefined
loadStories/</<@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:20821:17
loadStories/<@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:20814:13
render@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:11229:13
ConfigApi/this.configure@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:11264:9
configure@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:20921:15
configure@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:21366:24
./.storybook/generated-entry.js/<@http://localhost:6006/main.7a0ff0b8bf0e3413b462.bundle.js:16:67
./.storybook/generated-entry.js@http://localhost:6006/main.7a0ff0b8bf0e3413b462.bundle.js:17:30
__webpack_require__@http://localhost:6006/runtime~main.7a0ff0b8bf0e3413b462.bundle.js:785:30
hotApply@http://localhost:6006/runtime~main.7a0ff0b8bf0e3413b462.bundle.js:709:33
cb@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:178512:36
check/<@http://localhost:6006/vendors~main.7a0ff0b8bf0e3413b462.bundle.js:178527:11
没有标题的意外默认导出:未定义
loadStories/我解决这个问题的方法是使用扩展名“.stories.mdx”作为我的故事,在“.storybook/main.js”中,使用任何其他扩展名,如“.storybook.mdx”,给出了这个错误除了上面的解决方案之外,故事文件还需要有前缀,例如按钮.stories.mdx
只是故事。mdx
也会告诉你错误。这方面运气好吗?thx,这就是我的问题所在。伙计,我讨厌重复的上下文。很高兴它有帮助。仅供参考的故事书版本6.2.0将允许您使用stories.mdx