MDXContent is throwing error saying nothing was returned #2043
-
I am using storybook to add an addon which uses MDX. My code is similar to the docs, I import an mdx file, and pass it to the addon. storybook passes the data to the addon and I access it (as seen below). The issue that I am facing is that I am getting this error:
import { MDXProvider } from '@mdx-js/react';
import { addons, types } from '@storybook/addons';
import React from 'react';
addons.register('my-api', (api) => {
addons.add('my-api/tab', {
type: types.TAB,
title: 'API',
route: ({ storyId, refId }) => (refId ? `/api/${refId}_${storyId}` : `/api/${storyId}`),
match: ({ viewMode }) => viewMode === 'api',
render: () => {
const Page = api.getCurrentStoryData()?.parameters?.api?.page;
// console.table('md', typeof Page, Page, typeof Page === 'function' ? Page() : undefined);
return (
<div>
{
typeof Page === 'undefined' ?
<h2>No API setup for this Story.</h2> :
<Page />
}
</div>
);
},
});
}); Note: I have also tried this: Then in the story I have this: import Api from './button.api.mdx';
export default {
parameters: {
api: { page: Api }
}
} as Meta; I have asked on storybook and on stackoverflow but I have yet to get any answers on this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I don’t see any MDX being used. |
Beta Was this translation helpful? Give feedback.
I don’t see any MDX being used.
It helps if you cut down everything except the stuff that causes errors.
You’ll likely be best helped by Storybook folks: this is not an error that has been seen with MDX on its own.
One idea is that MDX in Storybook is, I believe, on V1. And we’re on V2. Perhaps you’re mixing versions, and downgrading the provider to v1 will help.