Closed
Description
Currently, we rely on componentWillReceiveProps
to perform sync update and sync forceUpdate
. So - this method does not exist anymore.
We have 2 options:
1 - rely on subrender, ie async updates. It is a dev mode, nobody cares about double rendering on rare hot updates. Thus remove AppContainer completely. This will also solve
2 - find another way. But I don't see any.
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
oliviertassinari commentedon Mar 31, 2018
Would it also explain why I see a warning anytime is use
getDerivedStateFromProps()
?I'm assuming react-hot-loader is hijacking the components and add
componentWillReceiveProps
.gregberge commentedon Mar 31, 2018
Yes, new challenge to come!
theKashey commentedon Mar 31, 2018
++ we have to test how new ("real") Context API works, as long "Context" is not a "Tag" or a function - it is a brand new element type. Should be fine, but even enzyme itself failing :)
theKashey commentedon Mar 31, 2018
@oliviertassinari - yeah, RHL is adding componentWillReceiveProps, and I am going just to drop it.
[-]No more componentWillReceiveProps [React 16.3][/-][+]Support React 16.3[/+]swashata commentedon Apr 2, 2018
Had just this issue right now. I am very new to react, just started and had to scratch my head (like a lot) to understand this isn't coming from mine, rather the hot loader 😁 . I will be waiting for an update.
Unsafe legacy lifecycles will not be called for components ...
keeps appearing facebook/react#12516gaearon commentedon Apr 2, 2018
I don't understand what this means:
theKashey commentedon Apr 2, 2018
@gaearon - this is a local meme( #830 ), about performing hot-render each time you "can do it". V3 uses AppContainer to start an update, v4 can use AppContainer to perform sync updates, and Component.render to perform async updates. Async cos they could be executed after the main update or main update could not "render into them" - code splitting, resource load, portals, and so on. Plus we have to defer .forceUpdate, as long shall not call it from a render method.
Basically - this one line - https://github.com/gaearon/react-hot-loader/blob/master/src/proxy/createClassProxy.js#L164
gaearon commentedon Apr 2, 2018
What are you using
componentWillReceiveProps
for today?theKashey commentedon Apr 2, 2018
Nothing but to being able "flush"(forceUpdate) changes. As I pointed above - we could safely remove it. It may cause double renders, but this is not something we should avoid.
Plus, if you move updates from a timeout to componentDidUpdate - they will be not so very deferred.
gaearon commentedon Apr 2, 2018
Got it.
componentWillReceiveProps
is a bad place to callforceUpdate
so that sounds good.theKashey commentedon Apr 2, 2018
PS: Is there any "new"(~fiber) way to trigger re-render? Is there any way to re-render SFC without a real Component on top of it? Is there any a bit more "soft" ways to update?
56 remaining items