Skip to content

Commit ac1bce3

Browse files
docs(README.md): add comment to handle React 18 createRoot API, fixes #157
1 parent e318cd3 commit ac1bce3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 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 = `
@@ -111,6 +112,24 @@ render(
111112
</Highlight>,
112113
document.getElementById('root')
113114
);
115+
116+
// If you are using React 18
117+
// const root = createRoot(document.getElementById('root'));
118+
// root.render(
119+
// <Highlight {...defaultProps} code={exampleCode} language="jsx">
120+
// {({ className, style, tokens, getLineProps, getTokenProps }) => (
121+
// <pre className={className} style={style}>
122+
// {tokens.map((line, i) => (
123+
// <div {...getLineProps({ line, key: i })}>
124+
// {line.map((token, key) => (
125+
// <span {...getTokenProps({ token, key })} />
126+
// ))}
127+
// </div>
128+
// ))}
129+
// </pre>
130+
// )}
131+
// </Highlight>
132+
// )
114133
```
115134

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

0 commit comments

Comments
 (0)