None of the demos I've seen for Draft-js (Facebook built on React) show how to clear the input field after posting. For example, see This code associated with awesome-draft-js , where the value you submit remains in the input field after submission. There is also no function in the api that seems to be designed for this. What I did for this is to create a new empty state when sending the button, for example,
onSubmit(){ this.setState({ editorState: EditorState.createEmpty(), }) }
However, since I create an empty state in the constructor when the editor loads like this
this.state = { editorState: EditorState.createEmpty(), };
I am worried that maybe I will not do it right, that is, the previous state object may become a memory leak. Question: what is the supposed way to reset the state in the above situation (i.e. submit button)
reactjs draftjs
Leahcim
source share