Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

reactjs - Clear state of text entered in TextInput when text is deleted


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are printing the textValue inside the _textchange function. The value doesn't change immediately. It will change the textValue after the whole function is executed completely.

 componentDidUpdate() {
    console.log(this.state.textValue)
 }

Add this snipper inside your class. This method will be executed whenever the state in your component changes...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...