Answers for "react clear input after button click"

0

react clear input after button click

<script type="text/babel">
    var StateComponent = React.createClass({
        resetName : function(event){
            this.setState({
                name : ''
            });
        },
        render : function(){
            return (
                <div>
                    <input type="text" value= {this.state.name}/>
                    <button onClick={this.resetName}>Reset</button>
                </div>
            )
        }
    });
    ReactDOM.render(<StateComponent/>, document.getElementById('app'));
</script>
Posted by: Guest on September-02-2021

Code answers related to "react clear input after button click"

Code answers related to "Javascript"

Browse Popular Code Answers by Language