@@ -117,12 +117,12 @@ A basic hello world:
117
117
118
118
``` jsx
119
119
import React from ' react'
120
- import ReactDom from ' react-dom'
120
+ import { createRoot } from ' react-dom/client '
121
121
import Markdown from ' react-markdown'
122
122
123
123
const markdown = ' # Hi, *Pluto*!'
124
124
125
- ReactDom . render (< Markdown> {markdown}< / Markdown> , document . body )
125
+ createRoot ( document . body ). render (< Markdown> {markdown}< / Markdown> )
126
126
```
127
127
128
128
<details >
@@ -142,15 +142,14 @@ directly):
142
142
143
143
``` jsx
144
144
import React from ' react'
145
- import ReactDom from ' react-dom'
145
+ import { createRoot } from ' react-dom/client '
146
146
import Markdown from ' react-markdown'
147
147
import remarkGfm from ' remark-gfm'
148
148
149
149
const markdown = ` Just a link: www.nasa.gov.`
150
150
151
- ReactDom .render (
152
- < Markdown remarkPlugins= {[remarkGfm]}> {markdown}< / Markdown> ,
153
- document .body
151
+ createRoot (document .body ).render (
152
+ < Markdown remarkPlugins= {[remarkGfm]}> {markdown}< / Markdown>
154
153
)
155
154
```
156
155
@@ -308,7 +307,7 @@ tables, tasklists and URLs directly:
308
307
309
308
` ` ` jsx
310
309
import React from ' react'
311
- import ReactDom from ' react-dom'
310
+ import { createRoot } from ' react-dom/client '
312
311
import Markdown from ' react-markdown'
313
312
import remarkGfm from ' remark-gfm'
314
313
@@ -326,9 +325,8 @@ A table:
326
325
| - | - |
327
326
`
328
327
329
- ReactDom .render (
330
- < Markdown remarkPlugins = {[remarkGfm ]}>{markdown}</Markdown>,
331
- document.body
328
+ createRoot (document .body ).render (
329
+ < Markdown remarkPlugins = {[remarkGfm ]}>{markdown}</Markdown>
332
330
)
333
331
```
334
332
@@ -379,17 +377,16 @@ strikethrough:
379
377
380
378
` ` ` jsx
381
379
import React from ' react'
382
- import ReactDom from ' react-dom'
380
+ import { createRoot } from ' react-dom/client '
383
381
import Markdown from ' react-markdown'
384
382
import remarkGfm from ' remark-gfm'
385
383
386
384
const markdown = ' This ~is not~ strikethrough, but ~~this is~~!'
387
385
388
- ReactDom .render (
386
+ createRoot ( document . body ) .render (
389
387
< Markdown remarkPlugins = {[[remarkGfm , {singleTilde: false }]]}>
390
388
{markdown}
391
- </Markdown>,
392
- document.body
389
+ </Markdown>
393
390
)
394
391
```
395
392
@@ -416,7 +413,7 @@ In this case, we apply syntax highlighting with the seriously super amazing
416
413
417
414
` ` ` jsx
418
415
import React from 'react'
419
- import ReactDom from 'react-dom'
416
+ import {createRoot} from 'react-dom/client '
420
417
import Markdown from 'react-markdown'
421
418
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'
422
419
import {dark} from 'react-syntax-highlighter/dist/esm/styles/prism'
@@ -429,7 +426,7 @@ console.log('It works!')
429
426
~~~
430
427
`
431
428
432
- ReactDom .render(
429
+ createRoot(document.body) .render(
433
430
<Markdown
434
431
children={markdown}
435
432
components={{
@@ -439,10 +436,10 @@ ReactDom.render(
439
436
return match ? (
440
437
<SyntaxHighlighter
441
438
{...rest}
439
+ PreTag="div"
442
440
children={String(children).replace(/\n $/, '')}
443
- style={dark}
444
441
language={match[1]}
445
- PreTag="div"
442
+ style={dark}
446
443
/>
447
444
) : (
448
445
<code {...rest} className={className}>
@@ -451,8 +448,7 @@ ReactDom.render(
451
448
)
452
449
}
453
450
}}
454
- />,
455
- document.body
451
+ />
456
452
)
457
453
` ` `
458
454
@@ -478,19 +474,18 @@ is used to support math in markdown, and a transform plugin
478
474
479
475
```jsx
480
476
import React from 'react'
481
- import ReactDom from 'react-dom'
477
+ import {createRoot} from 'react-dom/client '
482
478
import Markdown from 'react-markdown'
483
479
import rehypeKatex from 'rehype-katex'
484
480
import remarkMath from 'remark-math'
485
481
import 'katex/dist/katex.min.css' // `rehype-katex` does not import the CSS for you
486
482
487
483
const markdown = `The lift coefficient ($C_L$) is a dimensionless coefficient.`
488
484
489
- ReactDom .render(
485
+ createRoot(document.body) .render(
490
486
<Markdown remarkPlugins={[remarkMath ]} rehypePlugins={[rehypeKatex ]}>
491
487
{markdown}
492
- </Markdown>,
493
- document.body
488
+ </Markdown>
494
489
)
495
490
```
496
491
@@ -602,7 +597,7 @@ can spare the bundle size (±60kb minzipped), then you can use
602
597
603
598
` ` ` jsx
604
599
import React from ' react'
605
- import ReactDom from ' react-dom'
600
+ import { createRoot } from ' react-dom/client '
606
601
import Markdown from ' react-markdown'
607
602
import rehypeRaw from ' rehype-raw'
608
603
@@ -612,9 +607,8 @@ Some *emphasis* and <strong>strong</strong>!
612
607
613
608
</div> `
614
609
615
- ReactDom .render (
616
- < Markdown rehypePlugins = {[rehypeRaw ]}>{markdown}</Markdown>,
617
- document.body
610
+ createRoot (document .body ).render (
611
+ < Markdown rehypePlugins = {[rehypeRaw ]}>{markdown}</Markdown>
618
612
)
619
613
```
620
614
0 commit comments