3 ms·
It didn't need to happen in componentDidMount with multiple calls to setState. If it's not getting info that it would only know after mounting, it could have ha
by faceyspacey 10y ago
It didn't need to happen in componentDidMount with multiple calls to setState. If it's not getting info that it would only know after mounting, it could have happened in the same line that isConnected is initially defined within the constructor!
- faceyspacey 10y agoconstructor() { super() this.state = { isConnected: Math.floor(Math.random() * 10) > 5 } }
- tracker1 10y agoFor that matter, FB encourages the use of unidirectional workflows and simpler components... which means it could have been a pure function receiving props.