Giter Club home page Giter Club logo

Comments (9)

gaearon avatar gaearon commented on May 22, 2024

Thanks for reporting. Any idea why this happens?

from react-transform-hmr.

toddw avatar toddw commented on May 22, 2024

I'm not entirely sure. I noticed you talking about 'router.replaceRoutes' in the past. That has been removed and I'm not sure how the router handles new props. I started to think that the router was setting routes in state and not updating when it received new props. I'm still suspicious to this but then why does adding or removing a sibling make it suddenly work?

from react-transform-hmr.

kgdev avatar kgdev commented on May 22, 2024

Not working with Redux-Form too actually,

As long as there are high-order component decorators, react-proxy could not catch them and therefore the hot reload would fail.

e.g.
The code
@reduxForm() class MyComponent {...}
The tree is rendered as:
ReduxFormConnector --> ReduxForm --> MyComponent.

ReduxFormConnector and MyComponent are recognized and proxied by react-proxy. So far so good. However ReduxForm will not. So when there is a new module, a new ReduxForm is rendered. Because the type is different from the old one, the old ReduxForm instance is unmounted (so is MyComponent) and then the new ReduxForm instance is mounted. Therefore the state in MyComponent lost.

Any idea how to solve this problem? My current work around is to make sure ReduxFormConnector is not proxied. So I ignore any changes in ReduxFormConnector, but any changes in MyComponent will still be hot reloaded.

from react-transform-hmr.

gaearon avatar gaearon commented on May 22, 2024

Just executing the module again should not affect the parent component anyway. Yes, it's not recognised, but for this reason it is just ignored, and only child component (your class) is actually updated. Is this not what happens?

from react-transform-hmr.

kgdev avatar kgdev commented on May 22, 2024

For babel@5, only child component is proxied (which should be good). However for babel@6 with transform-decorators-legacy, the root component is proxied (and in this case it doesn't work)

from react-transform-hmr.

kgdev avatar kgdev commented on May 22, 2024

The work around is instead of writing:

   @reduxForm()
   export default class MyComponent {...}

I need to write:

    class MyComponent {...}

    @reduxForm()
    export default class extends MyComponent

from react-transform-hmr.

gaearon avatar gaearon commented on May 22, 2024

Oh okay. That's a Babel 6 plugin order issue I guess. The transform runs before the decorator transform. I think it will be fixed in Babel 7 by grouping plugin passes by preset. Don't rely on experimental language features :-)

from react-transform-hmr.

gaearon avatar gaearon commented on May 22, 2024

The new Babel 6.5.0 passPerPreset option might help here.

from react-transform-hmr.

gaearon avatar gaearon commented on May 22, 2024

I don’t see anything actionable for us here so closing. When <Router> learns to reload its routes in componentWillReceiveProps it will probably work again.

The Redux Form issue later in comments is completely unrelated to this issue and has to do with decorator usage. Don’t use decorators, they are far from being stable, and are too easy to break in Babel 6 because of plugin ordering issues.

from react-transform-hmr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.