Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove layoutProps from compiled output #1017

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions packages/mdx/mdx-hast-to-jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,12 @@ function toJSX(node, parentNode = {}, options = {}) {
const exportStatements = exportNodes
.map(childNode => toJSX(childNode, node))
.join('\n')
const layoutProps = `const layoutProps = {
${exportNames.join(',\n')}
};`
const mdxLayout = `const MDXLayout = ${layout ? layout : '"wrapper"'}`

const fn = `function MDXContent({ components, ...props }) {
return (
<MDXLayout
{...layoutProps}
${exportNames.map(name => ` ${name}={${name}}`).join('\n')}
{...props}
components={components}>
${jsxNodes.map(childNode => toJSX(childNode, node)).join('')}
Expand Down Expand Up @@ -157,7 +154,6 @@ MDXContent.isMDXComponent = true`
const moduleBase = `${importStatements}
${exportStatementsPostMdxTypeProps}
${fakedModulesForGlobalScope}
${layoutProps}
${mdxLayout}`

if (skipExport) {
Expand Down
13 changes: 2 additions & 11 deletions packages/mdx/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,10 @@ it('Should match sample blog post snapshot', async () => {
return <div {...props} />;
};

const layoutProps = {};
const MDXLayout = \\"wrapper\\";
export default function MDXContent({ components, ...props }) {
return (
<MDXLayout
{...layoutProps}
{...props}
components={components}
mdxType=\\"MDXLayout\\"
>
<MDXLayout {...props} components={components} mdxType=\\"MDXLayout\\">
<h1>{\`Hello World\`}</h1>
</MDXLayout>
);
Expand Down Expand Up @@ -338,15 +332,12 @@ test('Should handle layout props', () => {
};
const Foo = makeShortcode(\\"Foo\\");
const Bar = makeShortcode(\\"Bar\\");
const layoutProps = {
foo
};
const MDXLayout = ({children}) => <div>{children}</div>
export default function MDXContent({
components,
...props
}) {
return <MDXLayout {...layoutProps} {...props} components={components} mdxType=\\"MDXLayout\\">
return <MDXLayout foo={foo} {...props} components={components} mdxType=\\"MDXLayout\\">


<h1>{\`Hello, world!\`}</h1>
Expand Down
5 changes: 1 addition & 4 deletions packages/remark-mdx/test/__snapshots__/test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ const makeShortcode = name => function MDXDefaultShortcode(props) {
const Baz = makeShortcode(\\"Baz\\");
const Paragraph = makeShortcode(\\"Paragraph\\");
const Button = makeShortcode(\\"Button\\");
const layoutProps = {

};
const MDXLayout = Foo
export default function MDXContent({
components,
...props
}) {
return <MDXLayout {...layoutProps} {...props} components={components} mdxType=\\"MDXLayout\\">
return <MDXLayout {...props} components={components} mdxType=\\"MDXLayout\\">



Expand Down