I can't access the value of event.target.value from a React child Component, but I can from an HTML tag.
In the example given: it doesn't work for the Button tag (React Component) but works for the button tag (html tag).
import React from "react";
import Button from "./components/Button";
class Calculator extends React.Component {
constructor(props) {
super(props)
this.state = {
topText: "0"
}
this.handleClick = this.handleClick.bind(this);
}
handleClick(event) {
this.setState({ topText: event.target.value })
}
render() {
return (
<div>
<div>{this.state.topText}</div>
<Button value='1' onClick={this.handleClick}/>
<button value="2" onClick={this.handleClick}>2</button>
</div>
)
}
}
export default Calculator
./components/Button?