react clear input after button click

Solutions on MaxInterview for react clear input after button click by the best coders in the world

showing results for - "react clear input after button click"
Veronica
29 Nov 2017
1<script type="text/babel">
2    var StateComponent = React.createClass({
3        resetName : function(event){
4            this.setState({
5                name : ''
6            });
7        },
8        render : function(){
9            return (
10                <div>
11                    <input type="text" value= {this.state.name}/>
12                    <button onClick={this.resetName}>Reset</button>
13                </div>
14            )
15        }
16    });
17    ReactDOM.render(<StateComponent/>, document.getElementById('app'));
18</script>
19
similar questions
queries leading to this page
react clear input after button click