194 karma · joined Aug 5, 2014 (12y ago) · 37 submissions
comment 7y ago · link · parent
Sounds like you're talking about extensions in general, but for what it's worth- React DevTools doesn't require any super deep permissions¹ and all of the source code is in the open².
¹ https://github.com/bvaughn/react-devtools-experimental/blob/...
² https://github.com/bvaughn/react-devtools-experimental/tree/...
comment 8y ago · link · parent
Just in case there's any misunderstanding- (I don't think there is, but just being safe)- context isn't implicit. You have to opt into it either by using the `<Consumer>` component or a HOC that injects a context prop.
comment 8y ago · link · parent
The biggest one is probably adding event listeners or setting up subscriptions (which can cause memory leaks).
Here are some others: https://github.com/reactjs/rfcs/blob/master/text/0006-static...
> Is it correct to say that `getSnapshotBeforeUpdate` is named to indicate what you were supposed to use `componentWillMount` for?
No. `getSnapshotBeforeUpdate` is not really related to `componentWillMount`. It relates more to what people were using `componentWillUpdate` for.
comment 8y ago · link · parent
I did not mean to imply that you would need to step through every minor version though. I was just saying that- if you were using e.g. 15, update to the latest 15 release (15.6.2) and fixing warnings in it before updating to 16.
comment 8y ago · link · parent
Not if you use a HOC (e.g. `withContext(Component)`) like a couple of the docs examples showed.
> Additionally, the semantics of having a consumer's props.children be an immediately invoked function are a little bit unintuitive to me.
That's fair! I would encourage you to give it a chance though. I think it's a pattern that really grows on you after a short time. :)
comment 8y ago · link · parent
Sounds like it, based on your description!
> The other case of componentWillReceiveProps usage I see is where there is computationally expensive derived state, but for some reason the asynchronous nature of setState prevented it from being used, and an instance variable "had" to be used instead.
`setState` calls made from within `componentWillReceiveProps` are processed (synchronously) before `componentWillUpdate` or `render` are called.
comment 8y ago · link · parent
I've never used Hyperdom, so this isn't meant as a criticism or commentary on it.
comment 8y ago · link · parent
comment 8y ago · link · parent
https://reactjs.org/blog/2018/03/29/react-v-16-3.html#forwar...
comment 8y ago · link · parent
"fiber" was the code name for the rewrite that was released as version 16. Async rendering is a feature that we've been working on adding- (which the "fiber" rewrite was done to support). We've known that would take some time, mostly due to the fact that we want to gradually migrate old apps (as much as possible). :)
We're also working on other cool, related efforts- like a compiler (https://twitter.com/trueadm/status/944908776896978946) and proper built-in support for async-data, dubbed "suspense" (https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-...).
comment 8y ago · link · parent
The v16 rewrite (dubbed "fiber") wasn't just about cleaning up internals- it was about supporting a fundamentally different type of behavior- asynchronous rendering [1]
> Obviously no one is perfect, and hindsight is 20/20, but for such a "small" (yes, interacting with the dom is actually super duper hard, and edgecases abound) scope, I've seen more large-ish overhauls than I am comfortable with.
To be fair, React supports many more targets than just the DOM. In addition to the DOM- there's react-native, react-art, react-music, react-hardware, etc.
Don't mean to sound argumentative, just wanted to add some info in case there were potential misconceptions. :)
1: https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-...
comment 8y ago · link · parent
comment 8y ago · link · parent
What you're describing sounds more like you're updating something external (e.g. your Redux store). This isn't what the lifecycle is meant for, and you'd be better off using componentDidUpdate instead.
comment 8y ago · link · parent
If anything, I think the new context API (and even forwardRef itself) are endorsements of the render prop pattern more than of HOCs. :)
27.
React v16.3.0: New lifecycles and context API(reactjs.org ↗)
241 points · by brianvaughn · 8y ago · 129 comments
comment 8y ago · link · parent
And we provided a codemod to help with the "huge legacy apps": https://github.com/reactjs/react-codemod#rename-unsafe-lifec...
We've run it internally already to update ~14,000 components.
comment 8y ago · link · parent
And the codemod has already been released: https://github.com/reactjs/react-codemod#rename-unsafe-lifec...
We've used it internally (at Facebook) to update ~14,000 components already, so it's well tested.
comment 8y ago · link · parent
> You may notice in the example above that props.currentRow is mirrored in state (as state.lastRow). This enables getDerivedStateFromProps to access the previous props value in the same way as is done in componentWillReceiveProps.
> You may wonder why we don’t just pass previous props as a parameter to getDerivedStateFromProps. We considered this option when designing the API, but ultimately decided against it for two reasons:
> * A prevProps parameter would be null the first time getDerivedStateFromProps was called (after instantiation), requiring an if-not-null check to be added any time prevProps was accessed.
> * Not passing the previous props to this function is a step toward freeing up memory in future versions of React. (If React does not need to pass previous props to lifecycles, then it does not need to keep the previous props object in memory.)
1: https://reactjs.org/blog/2018/03/27/update-on-async-renderin...