react-ace
react-ace copied to clipboard
setHighlightSelectedWord not working
Hi there,
I just created a simple application with react-ace component.
I've noticed that when I'm writing the same word twice and select an occurrence - the other occurrence is not being highlighted although it should be.
I tried to use setHighlightSelectedWord(true) but the result is still the same.
Did it happen to anyone else?
Sorry, forgot to add the code:
import React from 'react';
import AceEditor from 'react-ace';
import brace from 'brace';
import 'brace/mode/sql';
import 'brace/theme/monokai'; // So we could use it as the "theme" prop
class App extends React.Component {
render() {
return <AceEditor
ref="aceEditor"
mode="sql"
theme="monokai"
fontSize="1em"
/>;
}
componentDidMount(){
this.refs.aceEditor.editor.setHighlightSelectedWord(true);
}
}
export default App;
Instead of using a componentDidMount, you can pass the editor options when rendering the editor initially:
import React from 'react';
import AceEditor from 'react-ace';
import brace from 'brace';
import 'brace/mode/sql';
import 'brace/theme/monokai'; // So we could use it as the "theme" prop
class App extends React.Component {
render() {
return <AceEditor
ref="aceEditor"
mode="sql"
theme="monokai"
fontSize="1em"
setOptions={{
highlightSelectedWord: true
}}
/>;
}
}
export default App;
Worked for me, let me know if it works for you
closing thanks @drewen !