From b8bedc9ef9d86463b74ba51b1cfe1a707b1a23fb Mon Sep 17 00:00:00 2001 From: John Otander Date: Fri, 31 Jul 2020 11:32:18 -0600 Subject: [PATCH] Remove layout props in compiled jsx (#1199) Closes #742 --- packages/mdx/mdx-hast-to-jsx.js | 11 +---------- packages/mdx/test/index.test.js | 13 ++----------- .../remark-mdxjs/test/__snapshots__/test.js.snap | 5 +---- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/packages/mdx/mdx-hast-to-jsx.js b/packages/mdx/mdx-hast-to-jsx.js index b25fb35eb..e270befbc 100644 --- a/packages/mdx/mdx-hast-to-jsx.js +++ b/packages/mdx/mdx-hast-to-jsx.js @@ -97,7 +97,7 @@ function serializeRoot(node, options) { const fn = `function MDXContent({ components, ...props }) { return ( - + ${doc} ) @@ -144,14 +144,6 @@ MDXContent.isMDXComponent = true` ] }).code - let layoutProps = 'const layoutProps = {' - - if (exportNames.length !== 0) { - layoutProps += '\n ' + exportNames.join(',\n ') + '\n' - } - - layoutProps += '};' - const allJsxNames = [ ...babelPluginApplyMdxPropInstance.state.names, ...babelPluginApplyMdxPropToExportsInstance.state.names @@ -173,7 +165,6 @@ MDXContent.isMDXComponent = true` const moduleBase = `${importStatements} ${exportStatementsPostMdxTypeProps} ${fakedModulesForGlobalScope} -${layoutProps} ${mdxLayout}` if (skipExport) { diff --git a/packages/mdx/test/index.test.js b/packages/mdx/test/index.test.js index f57e72ff3..c8ad44e75 100644 --- a/packages/mdx/test/index.test.js +++ b/packages/mdx/test/index.test.js @@ -54,16 +54,10 @@ it('Should match sample blog post snapshot', async () => { return
; }; - const layoutProps = {}; const MDXLayout = \\"wrapper\\"; export default function MDXContent({ components, ...props }) { return ( - +

{\`Hello World\`}

); @@ -340,15 +334,12 @@ test('Should handle layout props', () => { }; const Foo = makeShortcode(\\"Foo\\"); const Bar = makeShortcode(\\"Bar\\"); - const layoutProps = { - foo - }; const MDXLayout = ({children}) =>
{children}
export default function MDXContent({ components, ...props }) { - return + return

{\`Hello, world!\`}

{\`I'm an awesome paragraph.\`}

{ diff --git a/packages/remark-mdxjs/test/__snapshots__/test.js.snap b/packages/remark-mdxjs/test/__snapshots__/test.js.snap index 20a25064a..b29948a8e 100644 --- a/packages/remark-mdxjs/test/__snapshots__/test.js.snap +++ b/packages/remark-mdxjs/test/__snapshots__/test.js.snap @@ -10,15 +10,12 @@ const makeShortcode = name => function MDXDefaultShortcode(props) { }; const Paragraph = makeShortcode(\\"Paragraph\\"); const Button = makeShortcode(\\"Button\\"); -const layoutProps = { - Baz -}; const MDXLayout = Foo export default function MDXContent({ components, ...props }) { - return + return

{\`Hello, world! \`}