Where to Initialize State in React
class App extends React.Component { constructor(props) { // Required step: always call the parent class' constructor super(props); // Set the state directly. Use props if necessary. this.state = { loggedIn: false, currentState: "not-panic" someDefaultThing: this.props.whatever } } render() { // whatever you like } }
Source: www.codeproject.com