Are you first timer at Why not join us and start exchange your programming knowledge with everyone. Register today!

React - click to change render method to display state's value

0 votes
added Mar 8, 2019 in React by LC Marshal Captain (25,840 points)

Now we’ll change the Square’s render method to display the current state’s value when clicked:

class Square extends React.Component {
  constructor(props) {
    this.state = {
      value: null,
  render() {
    return (
      <button className="square" 
      onClick={() => this.setState({value: 'x'}) }

export default Square;


Please log in or register to response this reference. - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.