Answer (Choose 1 answer)
What shows in the paragraph when a user clicks the button?
class MyButton extends React.Component {
constructor() {
super();
this.state = {
x: 5
};
}
render() { return (
<div>
<p>{this.state.x}</p>
<button onClick={this.handleClick}>click me</button>
</div>
);
}
handleClick = () => {
this.state.x = 10;}
ReactDOM.render(<MyButton/>, document.getElementById("root"));
A. 5
B. 10
C. undefined
D. throw a error
(16