React defining state without constructor
I've seen some developers react to defining state without a constructor. I love the fact that it simplifies the code, but is it safe to do it?
class Dog extends React.Component {
state = { sound: 'Woof' }
return (
<p>Dog says { this.state.sound }</p>
)
}
I apologize in advance for the oversimplified simplified example.
+3
source to share