getDerivedStateFromPropsUNSAFE-prefixed versions of componentWillMount and componentWillUpdateStrictModecomponentWillMount, componentWillUpdate, componentWillReceiveProps.unstable_AsyncModeunstable_batchedUpdates in synchronous mode. Updates are flushed before React yields back to the browser.setTimeout, promise handlers, etc.unstable_createRootcreateBatch. Not quite ready to make this API stable.unstable_flushControlledunstable_deferredUpdates et al work when nested inside a lifecycle or other priority-changing function.react-reconcilerreact-reconciler/persistent, PR: https://github.com/facebook/react/pull/12156componentWillMount, componentWillUpdate, and componentWillReceiveProps, even outside strict mode.UNSAFE_ prefix if you want to keep using them.create-react-class and prop-types.componentWillReceiveProps, componentWillUpdate, componentWillMountrender method. It would take lots of effort to migrate, mostly because of class instance methods used as event handlers. The migration effort may not be worth it if we eventually introduce a new component API that replaces classes.unstable_batchedUpdates. We really should have made this stable a while ago, as it's clearly useful in synchronous mode. However, in asynchronous mode, it's effectively a no-op, so it would be weird to ask everyone to migrate to a new API, only to remove it in an upcoming release.unstable_AsyncMode. It's probably ready to be used in production, in a limited capacity, but we're holding off until we've tested it more internally. Tentative plan is to make this stable in 16.4.Does it make sense to have shallow rendering with the new context API? I see a couple of issues with that.
<Consumer> has to be rendered inside of a <Provider>. Can this be simulated through options the way that the old context is?children function passed to a <Consumer> won't actually be called during a shallow render, which means you can't test its output.Yeah, it's not clear to me if this makes sense or not either.
I am out of the loop, why is componentWillMount bad?
Please wait for the blog post. It'll explain everything. :-)
Is it too late to ask for s/getDerivedStateFromProps/deriveStateFromProps/?
Yeah. 馃槢 Please follow the RFCs to discuss early: https://github.com/reactjs/rfcs
We also intentionally added get* there because this API is rarely needed (so you shouldn't type it often) and it should be obvious you can't setState in it.
Guys, these breaking changes are looks like a waste of thousands man/hours for big projects.
What is a real benefit of these changes? I hope you know what you're doing)
There are no breaking changes here (in React 16.3, 16.4, or another minor 16.x release). React has always respected semver, and never introduced breaking changes to public APIs in minor versions.
What are you referring to?
Our major releases (like upcoming 17 that is months away) always had breaking changes. That鈥檚 literally the reason for doing major releases. We have 50 thousand React components at Facebook so we don鈥檛 make any breaking changes without a good migration path that works at scale.
@gaearon, we are waiting for a blog post that will "explain everything. :-)" and reassure us. 馃槍
@kvolkovich-sc
There must be sacrifices for progress
@kvolkovich-sc The blog post comes out together with the release. You can see the checklist for things to do before the release right above in this thread. I don't see the sense in adding to the pressure or creating the FUD in this thread.
Locking this so we can focus on getting the release out together with the blog post.
We should include the Enzyme folks in the shallow context discussion, since that will almost certainly affect the public API of shallow, I'm not sure if it can be worked around without support in the renderer tho.
Makes sense. Want to reach out to them?
Enzyme currently provides an API for setting legacy context when shallow rendering. Its reasonable to add a way to mock the Provider as well. I might expect the shallow renderer to act as if the Consumer components didn't exist. So the tree would render at the same depth it would render if there were no context providers, since there's no real reason to assert on Consumers directly
Most helpful comment
Yeah. 馃槢 Please follow the RFCs to discuss early: https://github.com/reactjs/rfcs
We also intentionally added
get*there because this API is rarely needed (so you shouldn't type it often) and it should be obvious you can'tsetStatein it.