@@ -117,12 +117,12 @@ A basic hello world:
117117
118118``` jsx
119119import React from ' react'
120- import ReactDom from ' react-dom'
120+ import { createRoot } from ' react-dom/client '
121121import Markdown from ' react-markdown'
122122
123123const markdown = ' # Hi, *Pluto*!'
124124
125- ReactDom . render (< Markdown> {markdown}< / Markdown> , document . body )
125+ createRoot ( document . body ). render (< Markdown> {markdown}< / Markdown> )
126126```
127127
128128<details >
@@ -142,15 +142,14 @@ directly):
142142
143143``` jsx
144144import React from ' react'
145- import ReactDom from ' react-dom'
145+ import { createRoot } from ' react-dom/client '
146146import Markdown from ' react-markdown'
147147import remarkGfm from ' remark-gfm'
148148
149149const markdown = ` Just a link: www.nasa.gov.`
150150
151- ReactDom .render (
152- < Markdown remarkPlugins= {[remarkGfm]}> {markdown}< / Markdown> ,
153- document .body
151+ createRoot (document .body ).render (
152+ < Markdown remarkPlugins= {[remarkGfm]}> {markdown}< / Markdown>
154153)
155154```
156155
@@ -308,7 +307,7 @@ tables, tasklists and URLs directly:
308307
309308` ` ` jsx
310309import React from ' react'
311- import ReactDom from ' react-dom'
310+ import { createRoot } from ' react-dom/client '
312311import Markdown from ' react-markdown'
313312import remarkGfm from ' remark-gfm'
314313
@@ -326,9 +325,8 @@ A table:
326325| - | - |
327326`
328327
329- ReactDom .render (
330- < Markdown remarkPlugins = {[remarkGfm ]}>{markdown}</Markdown>,
331- document.body
328+ createRoot (document .body ).render (
329+ < Markdown remarkPlugins = {[remarkGfm ]}>{markdown}</Markdown>
332330)
333331```
334332
@@ -379,17 +377,16 @@ strikethrough:
379377
380378` ` ` jsx
381379import React from ' react'
382- import ReactDom from ' react-dom'
380+ import { createRoot } from ' react-dom/client '
383381import Markdown from ' react-markdown'
384382import remarkGfm from ' remark-gfm'
385383
386384const markdown = ' This ~is not~ strikethrough, but ~~this is~~!'
387385
388- ReactDom .render (
386+ createRoot ( document . body ) .render (
389387 < Markdown remarkPlugins = {[[remarkGfm , {singleTilde: false }]]}>
390388 {markdown}
391- </Markdown>,
392- document.body
389+ </Markdown>
393390)
394391```
395392
@@ -416,7 +413,7 @@ In this case, we apply syntax highlighting with the seriously super amazing
416413
417414` ` ` jsx
418415import React from 'react'
419- import ReactDom from 'react-dom'
416+ import {createRoot} from 'react-dom/client '
420417import Markdown from 'react-markdown'
421418import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'
422419import {dark} from 'react-syntax-highlighter/dist/esm/styles/prism'
@@ -429,7 +426,7 @@ console.log('It works!')
429426~~~
430427`
431428
432- ReactDom .render(
429+ createRoot(document.body) .render(
433430 <Markdown
434431 children={markdown}
435432 components={{
@@ -439,10 +436,10 @@ ReactDom.render(
439436 return match ? (
440437 <SyntaxHighlighter
441438 {...rest}
439+ PreTag="div"
442440 children={String(children).replace(/\n $/, '')}
443- style={dark}
444441 language={match[1]}
445- PreTag="div"
442+ style={dark}
446443 />
447444 ) : (
448445 <code {...rest} className={className}>
@@ -451,8 +448,7 @@ ReactDom.render(
451448 )
452449 }
453450 }}
454- />,
455- document.body
451+ />
456452)
457453` ` `
458454
@@ -478,19 +474,18 @@ is used to support math in markdown, and a transform plugin
478474
479475```jsx
480476import React from 'react'
481- import ReactDom from 'react-dom'
477+ import {createRoot} from 'react-dom/client '
482478import Markdown from 'react-markdown'
483479import rehypeKatex from 'rehype-katex'
484480import remarkMath from 'remark-math'
485481import 'katex/dist/katex.min.css' // `rehype-katex` does not import the CSS for you
486482
487483const markdown = `The lift coefficient ($C_L$) is a dimensionless coefficient.`
488484
489- ReactDom .render(
485+ createRoot(document.body) .render(
490486 <Markdown remarkPlugins={[remarkMath ]} rehypePlugins={[rehypeKatex ]}>
491487 {markdown}
492- </Markdown>,
493- document.body
488+ </Markdown>
494489)
495490```
496491
@@ -602,7 +597,7 @@ can spare the bundle size (±60kb minzipped), then you can use
602597
603598` ` ` jsx
604599import React from ' react'
605- import ReactDom from ' react-dom'
600+ import { createRoot } from ' react-dom/client '
606601import Markdown from ' react-markdown'
607602import rehypeRaw from ' rehype-raw'
608603
@@ -612,9 +607,8 @@ Some *emphasis* and <strong>strong</strong>!
612607
613608</div> `
614609
615- ReactDom .render (
616- < Markdown rehypePlugins = {[rehypeRaw ]}>{markdown}</Markdown>,
617- document.body
610+ createRoot (document .body ).render (
611+ < Markdown rehypePlugins = {[rehypeRaw ]}>{markdown}</Markdown>
618612)
619613```
620614
0 commit comments