React-ace: How to access the content of the editor ?

Created on 4 Mar 2015  路  2Comments  路  Source: securingsincity/react-ace

When I use

handleChange(newValue) {
  this.setState({content: newValue});
}

it fails. Two change events are fired, one with the character typed, and the consecutive one with an empty string. But, interestingly, if I do this, it works.

handleChange(newValue) {
  console.log(newValue);
}

So, how do I get the value stored in the Ace editor ?

Most helpful comment

If you add a ref when you render the component, eg:

<AceEditor
    ref="ace"
    ...
/>

Then you can later access the entire content using:

this.refs.ace.editor.getValue();

All 2 comments

If you add a ref when you render the component, eg:

<AceEditor
    ref="ace"
    ...
/>

Then you can later access the entire content using:

this.refs.ace.editor.getValue();

Ah! Cool. Din't strike my mind even though I saw this.editor being used in the code.
Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tsmirnov picture tsmirnov  路  4Comments

anderoonies picture anderoonies  路  5Comments

BenBrewerBowman picture BenBrewerBowman  路  5Comments

dmavrin picture dmavrin  路  3Comments

Jarmahent picture Jarmahent  路  3Comments