Closed murtyjones closed 6 years ago
No need to store the ref yourself, just manipulate the instance given to you! In this case, we'll persist it in editorDidMount
(most a lot of callbacks in the docs pass this back). This keeps coming up - I think I'll add a "getting the instance" piece to the readme...
constructor() {
this.instance = null; // store here on `editorDidMount`
}
render() {
<CodeMirror editorDidMount={(editor) => { this.instance = editor }}/>
}
then you can this.instance.addLineClass((nextState.errorLine - 1), 'errorLine')
Thanks! I also realized that I forgot an argument in addLineClass. In my case, it should've been:
this.codeMirror.addLineClass((nextState.errorLine - 1), 'wrap', 'errorLine')
rather than:
this.codeMirror.addLineClass((nextState.errorLine - 1), 'errorLine')
it's working now. Thanks again.
Is it possible to access commands such as addLineClass in react-codemirror2?
I was attempting to set the node like so:
and add a class to a line like so:
No luck though.