<div id="app"></div>
class F extends React.Component {
  constructor(props) {
    super(props);
    this.state = { a: new Date(),
                 b: "1",
                 c: [1,2,3],
                 d: {foo: "bar"}
                 }
  }
  
  c = () => {
    let { a, b, c, d  } = this.state
    this.setState({a: new Date(),
                  b: 2,
                  c: [...this.state.c, 4],
                  d: {...this.state.d, baz: "bam"}
                  }, () =>
    {
      alert(`hi ${this.state.a}, ${a}, 
            ${this.state.b}, ${b}, 
            ${this.state.c}, ${c},
            ${JSON.stringify(this.state.d)}), ${JSON.stringify(d)}`
            )  
    })
    
  }
  
  render = () => {
    return (
      <button onClick={this.c}>Hello</button>
      )
  }
}


ReactDOM.render(<F />, document.getElementById('app'))
View Compiled
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/16.12.0/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.11.0/umd/react-dom.production.min.js