Skip to content

Commit 9cb3d50

Browse files
Merge pull request #158 from FormidableLabs/docs/readme-react-18
Docs: Update README for React 18 ReactDOM.createRoot API
2 parents e318cd3 + e02d234 commit 9cb3d50

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ yarn add prism-react-renderer
8484
```jsx
8585
import React from "react";
8686
import { render } from "react-dom";
87+
// import { createRoot } from "react-dom/client";
8788
import Highlight, { defaultProps } from "prism-react-renderer";
8889

8990
const exampleCode = `
@@ -95,7 +96,7 @@ const exampleCode = `
9596
return () => <App />;
9697
`;
9798

98-
render(
99+
const Content = (
99100
<Highlight {...defaultProps} code={exampleCode} language="jsx">
100101
{({ className, style, tokens, getLineProps, getTokenProps }) => (
101102
<pre className={className} style={style}>
@@ -108,9 +109,13 @@ render(
108109
))}
109110
</pre>
110111
)}
111-
</Highlight>,
112-
document.getElementById('root')
112+
</Highlight>
113113
);
114+
render(Content, document.getElementById('root'));
115+
116+
// If you are using React 18
117+
// const root = createRoot(document.getElementById('root'));
118+
// root.render(Content);
114119
```
115120

116121
`<Highlight />` is the only component exposed by this package, as inspired by

0 commit comments

Comments
 (0)