Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ yarn add prism-react-renderer
```jsx
import React from "react";
import { render } from "react-dom";
// import { createRoot } from "react-dom/client";
import Highlight, { defaultProps } from "prism-react-renderer";

const exampleCode = `
Expand All @@ -95,7 +96,7 @@ const exampleCode = `
return () => <App />;
`;

render(
const Content = (
<Highlight {...defaultProps} code={exampleCode} language="jsx">
{({ className, style, tokens, getLineProps, getTokenProps }) => (
<pre className={className} style={style}>
Expand All @@ -108,9 +109,13 @@ render(
))}
</pre>
)}
</Highlight>,
document.getElementById('root')
</Highlight>
);
render(Content, document.getElementById('root'));

// If you are using React 18
// const root = createRoot(document.getElementById('root'));
// root.render(Content);
```

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