change clicked button text in react code example
Example 1: get value of input element on button click react
const input = props => {
let textInput = React.createRef();
function handleClick() {
console.log(textInput.current.value);
}
return (
<div>
<input ref={textInput} placeholder="Type a message..." />
<div onClick={handleClick} className="icon">
<i className="fa fa-play" />
</div>
</div>
)
}
Example 2: change the value in checkbox by button react
<input type="checkbox" checked={this.state.chkbox} onChange={this.handleChangeChk} />