Skip to content

Commit 3ecbf8a

Browse files
committed
Updating Readme with better docs
1 parent b1660ef commit 3ecbf8a

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Codemirror
22

3-
The excellent CodeMirror editor as a React.js component.
3+
The excellent [CodeMirror](https://codemirror.net) editor as a [React.js](http://facebook.github.io/react) component.
44

55

66
## Demo & Examples
77

8-
Live demo: [JedWatson.github.io/react-codemirror](http://JedWatson.github.io/react-codemirror/)
8+
Live demo: [JedWatson.github.io/react-codemirror](http://JedWatson.github.io/react-codemirror)
99

1010
To build the examples locally, run:
1111

@@ -31,11 +31,29 @@ npm install codemirror --save
3131
## Usage
3232

3333
```
34-
// TODO: value, onChange example
35-
36-
var Codemirror = require('codemirror');
37-
38-
<Codemirror />
34+
var React = require('react'),
35+
Codemirror = require('react-codemirror');
36+
37+
var App = React.createClass({
38+
getInitialState: function() {
39+
return {
40+
code: "// Code"
41+
};
42+
},
43+
updateCode: function(newCode) {
44+
this.setState({
45+
code: newCode
46+
});
47+
},
48+
render: function() {
49+
var options = {
50+
lineNumbers: true
51+
};
52+
return <Codemirror value={this.state.code} onChange={this.updateCode} options={options} />
53+
}
54+
});
55+
56+
React.render(<App />, document.getElementById('app'));
3957
```
4058

4159
### Properties
@@ -44,6 +62,8 @@ var Codemirror = require('codemirror');
4462
* `options` `Object (newValue)` options passed to the CodeMirror instance
4563
* `onChange` `Function (newValue)` called when a change is made
4664

65+
See the [CodeMirror API Docs](https://codemirror.net/doc/manual.html#api) for the available options.
66+
4767
### License
4868

4969
MIT. Copyright (c) 2015 Jed Watson.

0 commit comments

Comments
 (0)