I have seen some reactjs courses where the component state is directly initialized without using a constructor as shown below.
class App extends React.Component {
state = {
text: 'hello world'
}
render() {
return <div><h4>{this.state.text}</h4></div>
}
}
ReactDOM.render(<App/>,document.getElementById('root'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="root"></div>
Is this a recommended way to initialize component state without wrapping it in a constructor?