Skip to content

Support React 16.3 #918

Closed
Closed
@theKashey

Description

@theKashey

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.

Activity

oliviertassinari

oliviertassinari commented on Mar 31, 2018

@oliviertassinari
Contributor

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 .

capture d ecran 2018-03-31 a 13 20 33

gregberge

gregberge commented on Mar 31, 2018

@gregberge
Collaborator

Yes, new challenge to come!

theKashey

theKashey commented on Mar 31, 2018

@theKashey
CollaboratorAuthor

++ 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

theKashey commented on Mar 31, 2018

@theKashey
CollaboratorAuthor

@oliviertassinari - yeah, RHL is adding componentWillReceiveProps, and I am going just to drop it.

changed the title [-]No more componentWillReceiveProps [React 16.3][/-] [+]Support React 16.3[/+] on Apr 1, 2018
swashata

swashata commented on Apr 2, 2018

@swashata

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.

gaearon

gaearon commented on Apr 2, 2018

@gaearon
Owner

I don't understand what this means:

rely on subrender, ie async updates.

theKashey

theKashey commented on Apr 2, 2018

@theKashey
CollaboratorAuthor

@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

gaearon commented on Apr 2, 2018

@gaearon
Owner

What are you using componentWillReceiveProps for today?

theKashey

theKashey commented on Apr 2, 2018

@theKashey
CollaboratorAuthor

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

gaearon commented on Apr 2, 2018

@gaearon
Owner

Got it. componentWillReceiveProps is a bad place to call forceUpdate so that sounds good.

theKashey

theKashey commented on Apr 2, 2018

@theKashey
CollaboratorAuthor

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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @swrobel@gregberge@theKashey@gaearon@elisherer

      Issue actions

        Support React 16.3 · Issue #918 · gaearon/react-hot-loader