Skip to content

Commit

Permalink
perf(mdx): optimize mdx related components render performance (#827)
Browse files Browse the repository at this point in the history
close #826
  • Loading branch information
sabertazimi committed May 8, 2022
1 parent c11ac10 commit 4854f81
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
5 changes: 1 addition & 4 deletions components/Article/ArticleContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import MDX from '@components/MDX';
import { Ease } from '@components/Motion';
import type { Post } from '@types';
import { MDXRemote } from 'next-mdx-remote';

Expand All @@ -8,9 +7,7 @@ interface Props {
}

const ArticleContent = ({ source }: Props): JSX.Element => (
<Ease>
<MDXRemote {...source} components={MDX} />
</Ease>
<MDXRemote {...source} components={MDX} />
);

export default ArticleContent;
24 changes: 8 additions & 16 deletions components/Article/__snapshots__/Article.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,11 @@ exports[`Article should render correctly (snapshot) 1`] = `
<div
class="container relative block h-full mx-auto my-0 p-auto max-w-screen-lg px-6"
>
<div
style="opacity: 0;"
<h2
class="ant-typography mb-6 after:ml-1 hover:after:content-['#'] hover:after:text-primary dark:text-light mt-24"
>
<h2
class="ant-typography mb-6 after:ml-1 hover:after:content-['#'] hover:after:text-primary dark:text-light mt-24"
>
1 Basic Notes
</h2>
</div>
1 Basic Notes
</h2>
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-center mx-0 my-12 leading-relaxed tracking-wide font-extrabold dark:border-light dark:text-light"
role="separator"
Expand Down Expand Up @@ -586,15 +582,11 @@ exports[`Article should render correctly with partial data (snapshot) 1`] = `
<div
class="container relative block h-full mx-auto my-0 p-auto max-w-screen-lg px-6"
>
<div
style="opacity: 0;"
<h2
class="ant-typography mb-6 after:ml-1 hover:after:content-['#'] hover:after:text-primary dark:text-light mt-24"
>
<h2
class="ant-typography mb-6 after:ml-1 hover:after:content-['#'] hover:after:text-primary dark:text-light mt-24"
>
1 Basic Notes
</h2>
</div>
1 Basic Notes
</h2>
<div
class="ant-divider ant-divider-horizontal ant-divider-with-text ant-divider-with-text-center mx-0 my-12 leading-relaxed tracking-wide font-extrabold dark:border-light dark:text-light"
role="separator"
Expand Down
14 changes: 14 additions & 0 deletions components/Motion/Ease.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render } from '@testing-library/react';
import Ease from './Ease';

describe('Ease', () => {
test('should render correctly (snapshot)', () => {
const { container } = render(
<Ease>
<div>Ease</div>
</Ease>
);

expect(container).toMatchSnapshot();
});
});
13 changes: 13 additions & 0 deletions components/Motion/__snapshots__/Ease.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Ease should render correctly (snapshot) 1`] = `
<div>
<div
style="opacity: 0;"
>
<div>
Ease
</div>
</div>
</div>
`;

1 comment on commit 4854f81

@vercel
Copy link

@vercel vercel bot commented on 4854f81 May 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blog – ./

blog-sabertaz.vercel.app
blog-git-main-sabertaz.vercel.app
blog.tazimi.dev

Please sign in to comment.