GithubHelp home page GithubHelp logo

Comments (15)

aaronjensen avatar aaronjensen commented on April 27, 2024

I believe this has to do w/ some incorrect stuff that was happening in the app, though I don't know exactly what yet. This may be something that should never normally happen.

from react-redux.

aaronjensen avatar aaronjensen commented on April 27, 2024

Ok, so here's what we were doing... in componentWillMount we fired an action via setTimeout so that the react-redux subscription in componentDidMount will have already happened by the time the action is dispatched. It appears that this is a bad idea, though I do not understand why.

from react-redux.

gaearon avatar gaearon commented on April 27, 2024

OK I introduced this bug while tweaking @gnoff's code. :-(
Will push out a fix soon.

from react-redux.

gaearon avatar gaearon commented on April 27, 2024

Can you verify the bug is fixed in 0.5.1?

from react-redux.

aaronjensen avatar aaronjensen commented on April 27, 2024

yep, it is. But then I get this:

Uncaught Error: Invariant Violation: Component (with keys: getDOMNode,_handleChange,props,context,state,refs,_reactInternalInstance) contains `render` method but is not mounted in the DOM

which makes me think we're doing something very wrong. By removing the setTimeout in componentWillMount it works out.

What's the right way to fire an action when a component mounts? If the action immediately modifies state, componentWillMount is too soon, because react-redux doesn't subscribe until componentDidMount...

from react-redux.

gaearon avatar gaearon commented on April 27, 2024

contains render method but is not mounted in the DOM

I found this: facebook/react#4233.

Sounds like React throws if you use findDOMNode(this) when component is already unmounted. You should clear any previously set interval in componentWillUnmount.

If the action immediately modifies state, componentWillMount is too soon, because react-redux doesn't subscribe until componentDidMount.

What do you mean by "too soon"? If React Redux doesn't update in some edge case, it's a bug, no matter where you call dispatch! You should file an issue, not just accept it like that. 😄

from react-redux.

aaronjensen avatar aaronjensen commented on April 27, 2024

I just assume that you've thought of everything and there's a good reason it is as it is! I'll make sure it is what I think it is and file an issue when I get a sec. Thanks!

from react-redux.

gaearon avatar gaearon commented on April 27, 2024

Keeping it open for now so I don't forget about it.
I make mistakes all the time, you should help me figure them out!

from react-redux.

gaearon avatar gaearon commented on April 27, 2024

Ideally, the fastest way to figure out a solution is to discuss a failing test. Can I ask you to contribute it?

from react-redux.

aaronjensen avatar aaronjensen commented on April 27, 2024

Looks like you beat me to it! feel free to close #31, thanks. Btw, is there a reason to do it this way instead of by subscribing in componentWillMount?

from react-redux.

gaearon avatar gaearon commented on April 27, 2024

Yes, componentWillMount executes on server. This would cause memory leaks.

from react-redux.

aaronjensen avatar aaronjensen commented on April 27, 2024

The second error I saw is actually this: facebook/react#2410

I'm not sure why yet, in my case, it has to do w/ clicking submit on a form triggering a router transition. I'll keep digging

from react-redux.

gaearon avatar gaearon commented on April 27, 2024

If you can reliably reproduce it on a small project let the folks know. It could be a React bug after all.

Are you by chance using React.addons.batchedUpdates or similar? Not saying I understand the issue but if so, try removing it and check if it makes the bug go away. I've heard about problems with batching and inputs although not sure what kind. Sorry if this is too vague. :-)

from react-redux.

aaronjensen avatar aaronjensen commented on April 27, 2024

We are, but removing it has no effect. I'll work on a small repro.

from react-redux.

aaronjensen avatar aaronjensen commented on April 27, 2024

You may be following that thread, so you may have seen it, but here's a repro: https://github.com/aaronjensen/react-2410-repro

The error does not happen if this line is removed: https://github.com/aaronjensen/react-2410-repro/blob/master/app/create_router.jsx#L10

from react-redux.

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.