Skip to content

Commit 4067185

Browse files
committed
Update README.md
1 parent 38c6e41 commit 4067185

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

README.md

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,54 @@
2626
A markdown editor with preview, implemented with React.js and TypeScript.
2727
</p>
2828

29-
## Quick Start
29+
## Install
3030

3131
```bash
3232
npm i @uiwjs/react-markdown-editor
33-
```
33+
```
34+
35+
## Basic Usage
36+
37+
```jsx
38+
import MarkdownEditor from '@uiwjs/react-markdown-editor';
39+
import React from 'react';
40+
import ReactDOM from 'react-dom';
41+
42+
43+
class App extends React.Component {
44+
constructor() {
45+
super();
46+
this.state = {
47+
markdown: '# This is a H1 \n## This is a H2 \n###### This is a H6',
48+
};
49+
this.updateMarkdown = this.updateMarkdown.bind(this);
50+
}
51+
52+
updateMarkdown(value) {
53+
this.setState({ markdown: value });
54+
}
55+
56+
render() {
57+
return (
58+
<MarkdownEditor
59+
value={this.state.markdown}
60+
onChange={this.updateMarkdown}
61+
/>
62+
);
63+
}
64+
}
65+
66+
ReactDOM.render(
67+
<App />,
68+
document.getElementById('app')
69+
);
70+
```
71+
72+
## Props
73+
74+
- value (*string*) - the raw markdown that will be converted to html (**required**)
75+
- onChange (*function*) - called when a change is made (**required**)
76+
77+
## License
78+
79+
[MIT © Kenny Wong](./LICENSE)

0 commit comments

Comments
 (0)