I was going through my code and realized I sometimes assign a logic when declaring the state and other times at ComponentDidMount.
constructor(props) {
super(props);
this.state = {
api: localStorage.getItem("api") ? true : false,
};
other times I do this instead
constructor(props) {
super(props);
this.state = {
api: null,
};
componentDidMount() {
this.setState({api: localStorage.getItem("api") ? true : false})
}
They seem to behave the same way but I am sure there are a few subtle differences. which one is the most correct?