Skip to content

Commit

Permalink
Use MDXContext directly (#4267)
Browse files Browse the repository at this point in the history
* Use MDXContext directly

* yolo
  • Loading branch information
gaearon authored Feb 1, 2022
1 parent 58d6f3f commit abca1f4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions beta/src/components/Layout/LayoutPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {MDXProvider} from '@mdx-js/react';
// @ts-ignore
import {MDXContext} from '@mdx-js/react';
import recentPostsRouteTree from 'blogIndexRecent.json';
import {DocsPageFooter} from 'components/DocsFooter';
import {ExternalLink} from 'components/ExternalLink';
Expand Down Expand Up @@ -87,7 +88,9 @@ function LayoutPost({meta, children}: LayoutPostProps) {
</span>
</p>

<MDXProvider components={MDXComponents}>{children}</MDXProvider>
<MDXContext.Provider value={MDXComponents}>
{children}
</MDXContext.Provider>
<DocsPageFooter
route={route}
nextRoute={nextRoute}
Expand Down
7 changes: 4 additions & 3 deletions beta/src/components/Layout/MarkdownPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*/

import * as React from 'react';
import {MDXProvider} from '@mdx-js/react';
// @ts-ignore
import {MDXContext} from '@mdx-js/react';
import {DocsPageFooter} from 'components/DocsFooter';
import {MDXComponents} from 'components/MDX/MDXComponents';
import {Seo} from 'components/Seo';
Expand Down Expand Up @@ -135,9 +136,9 @@ export function MarkdownPage<
)}
<div className="px-5 sm:px-12">
<div className="max-w-7xl mx-auto">
<MDXProvider components={MDXComponents}>
<MDXContext.Provider value={MDXComponents}>
{finalChildren}
</MDXProvider>
</MDXContext.Provider>
</div>
<DocsPageFooter
route={route}
Expand Down

0 comments on commit abca1f4

Please sign in to comment.