<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
This Pen doesn't use any external CSS resources.