I've seen some react developers define state without a constructor. I like the fact that is simplifies the code, but is it safe to do so?
class Dog extends React.Component {
state = { sound: 'Woof' }
return (
<p>Dog says { this.state.sound }</p>
)
}
I apologize in advance for the over simplified example.
Its exactly the same thing. Take a look at the javascript that babel transpiles the code into. There is no difference.