Even with state, his code is overly verbose and can be expressed in a much more idiomatic way.
var weAreConnected = Math.floor(Math.random() * 10) > 5;
if (weAreConnected === true) {
this.setState({
isConnected: true
})
}
else {
this.setState({
isConnected: false
})
}
}
turns into
var weAreConnected = Math.floor(Math.random() * 10) > 5;
this.setState({
isConnected: weAreConnected
});
It's almost like he wrote it in the most obtuse way possible to prove his point. Unless he writes like that normally; If so then I can see where he's getting all these errors from.