react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Remove deadcode in Link

Open bondz opened this issue 1 year ago • 2 comments
trafficstars

This PR removes deadcode in the Link Component when the Link component contains a <code ... /> element. As seen in this example.


In the modifiedChildren array here https://github.com/reactjs/react.dev/blob/6ca0381a0762f1de4a49052700723664e92db030/src/components/MDX/Link.tsx#L19-L26

The if block always evaluates to false because child.type?.mdxName === 'inlineCode' for the code element is code per https://github.com/reactjs/react.dev/blob/6ca0381a0762f1de4a49052700723664e92db030/src/components/MDX/MDXComponents.tsx#L403 https://github.com/reactjs/react.dev/blob/6ca0381a0762f1de4a49052700723664e92db030/src/components/MDX/MDXComponents.tsx#L452

An alternative would be to fix the code to apply the style https://github.com/reactjs/react.dev/blob/6ca0381a0762f1de4a49052700723664e92db030/src/components/MDX/InlineCode.tsx#L21 but I figure its been working fine without it?

I've also tested the site and it works just fine without it. The only other place inlineCode is mentioned is https://github.com/reactjs/react.dev/blob/6ca0381a0762f1de4a49052700723664e92db030/plugins/remark-smartypants.js#L39 but I'm unsure if that is related.

bondz avatar Feb 02 '24 08:02 bondz

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
react-dev ✅ Ready (Inspect) Visit Preview Feb 2, 2024 8:23am

vercel[bot] avatar Feb 02 '24 08:02 vercel[bot]

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 79.06 KB (🟢 -36 B) 182.92 KB
/500 79.06 KB (🟢 -36 B) 182.92 KB
/[[...markdownPath]] 80.66 KB (🟢 -36 B) 184.51 KB
/errors 79.24 KB (🟢 -36 B) 183.1 KB
/errors/[errorCode] 79.22 KB (🟢 -36 B) 183.08 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

github-actions[bot] avatar Feb 02 '24 08:02 github-actions[bot]