Last active
June 28, 2018 14:08
-
-
Save jotak/7d3398f25182ba58d75bf6f82a1ae1b0 to your computer and use it in GitHub Desktop.
Reproducer - react-ace issue #300
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import { render } from 'react-dom'; | |
import AceEditor from '../src/ace.js'; | |
import 'brace/mode/yaml'; | |
import 'brace/theme/eclipse'; | |
/*eslint-disable no-alert, no-console */ | |
const yamlSource1 = `Initial | |
text`; | |
const yamlSource2 = `Modified | |
text`; | |
const annotations = [{ row: 0, column: 0, text: 'error.message', type: 'error' }]; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
annotations: undefined, | |
yml: yamlSource1 | |
}; | |
} | |
addErrorWorking = () => { | |
this.setState({ | |
annotations: annotations, | |
yml: yamlSource1 | |
}); | |
} | |
addErrorNotWorking = () => { | |
this.setState({ | |
annotations: annotations, | |
yml: yamlSource2 | |
}); | |
} | |
rmError = () => { | |
this.setState({ | |
annotations: [], | |
markers: [], | |
yml: yamlSource1 | |
}); | |
} | |
render() { | |
return ( | |
<div> | |
<AceEditor | |
value={this.state.yml} | |
annotations={this.state.annotations} | |
/><br/><br/> | |
<button onClick={this.addErrorWorking}>Add error working</button> | |
<button onClick={this.addErrorNotWorking}>Add error not working</button> | |
<button onClick={this.rmError}>Rm error</button> | |
</div> | |
); | |
} | |
} | |
render( | |
<App />, | |
document.getElementById('example') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment