newprint newprint - 3 months ago 17
React JSX Question

How to get the value of react component - AceEditor

I am facing the following issue while using

AceEditor
react component https://github.com/securingsincity/react-ace

I am using
AceEditor
as user input, after user enters code, he(she) presses the
Run
button. (see the picture) How do I extract the text that users enters from
AceEditor
component ? enter image description here

Answer

You need to subscribe to the onChange event (explained in the docs) and store the value passed into the callback somewhere, perhaps in the component's state if the Run button is on the same page. Then, when user clicks the button just retrieve it via this.state.xxx

Comments