Skip to content

Instantly share code, notes, and snippets.

@jotak
Last active June 28, 2018 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jotak/7d3398f25182ba58d75bf6f82a1ae1b0 to your computer and use it in GitHub Desktop.
Save jotak/7d3398f25182ba58d75bf6f82a1ae1b0 to your computer and use it in GitHub Desktop.
Reproducer - react-ace issue #300
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