Skip to content

Commit 06b310f

Browse files
committed
doc: Update README.md (#214).
1 parent fa2c5c8 commit 06b310f

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,44 @@ npm install @uiw/react-code-preview --save
2121

2222
[![Open in CodeSandbox](https://img.shields.io/badge/Open%20in-CodeSandbox-blue?logo=codesandbox)](https://codesandbox.io/embed/polished-surf-t6ro9?fontsize=14&hidenavigation=1&theme=dark)
2323

24+
### In React 18
25+
2426
```jsx
2527
import Button from '@uiw/react-button';
2628
import CodePreview from '@uiw/react-code-preview';
2729

2830
const code = `import Button from '@uiw/react-button';
31+
import ReactDOMClient from 'react-dom/client';
32+
33+
ReactDOM.render(
34+
<div>
35+
<Button type="primary">主要按钮</Button>
36+
<Button type="success">成功按钮</Button>
37+
</div>,
38+
_mount_
39+
);`;
40+
41+
export default function App() {
42+
return <CodePreview code={code} dependencies={{ Button }} />;
43+
}
44+
```
45+
46+
### In React 17
47+
48+
```jsx
49+
import Button from '@uiw/react-button';
50+
import CodePreview from '@uiw/react-code-preview';
51+
52+
const code = `import Button from '@uiw/react-button';
53+
import ReactDOM from 'react-dom';
54+
2955
ReactDOM.render(
3056
<div>
3157
<Button type="primary">主要按钮</Button>
3258
<Button type="success">成功按钮</Button>
3359
</div>,
3460
_mount_
35-
);
36-
`;
61+
);`;
3762

3863
export default function App() {
3964
return <CodePreview code={code} dependencies={{ Button }} />;

0 commit comments

Comments
 (0)