docs: wrap more JSX in mdx-code-block (#7568)

This commit is contained in:
Joshua Chen 2022-06-05 15:41:06 +08:00 committed by GitHub
parent 6d481f6a29
commit c03def7d5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 1 deletions

View file

@ -36,9 +36,10 @@ ReferenceError: window is not defined
This is because during server-side rendering, the Docusaurus app isn't actually run in browser, and it doesn't know what `window` is.
```mdx-code-block
<details id="node-env">
<summary>What about <code>process.env.NODE_ENV</code>?</summary>
```
One exception to the "no Node globals" rule is `process.env.NODE_ENV`. In fact, you can use it in React, because Webpack injects this variable as a global:
@ -58,8 +59,10 @@ During Webpack build, the `process.env.NODE_ENV` will be replaced with the value
import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';
```mdx-code-block
<Tabs>
<TabItem value="Development">
```
```diff
import React from 'react';
@ -74,8 +77,10 @@ export default function expensiveComp() {
}
```
```mdx-code-block
</TabItem>
<TabItem value="Production">
```
```diff
import React from 'react';
@ -90,9 +95,11 @@ export default function expensiveComp() {
}
```
```mdx-code-block
</TabItem>
</Tabs>
</details>
```
## Understanding SSR {#understanding-ssr}