4 ms·
For the first two examples, there's some unfamiliar syntax because they added Flow[1] typings to the examples (not TypeScript as other comments are suggesting).
by m0meni 9y ago
For the first two examples, there's some unfamiliar syntax because they added Flow[1] typings to the examples (not TypeScript as other comments are suggesting).
What about the syntax do you find confusing? The rest is all just ES6 + class properties.
[1]: https://github.com/facebook/flow https://github.com/facebook/flow
- bringtheaction 9y agoCan someone explain to me why they went for static getDerivedStateFromProps(nextProps, prevState) Instead of getDerivedStateFromProps(nextProps) Was it to prevent people from mutating the object perhaps?
- danabramov 9y agoYes, since that’s the most common issue with what people do in componentWillReceiveProps. It is invoked during the interruptible phase in async mode so mutations and side effects are unsafe there. Same as in the render method.