Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will probably not work on advanced usecases #1

Closed
slorber opened this issue Jan 29, 2016 · 5 comments
Closed

Will probably not work on advanced usecases #1

slorber opened this issue Jan 29, 2016 · 5 comments

Comments

@slorber
Copy link

slorber commented Jan 29, 2016

Hi,

When an action is dispatched and connect's HOC are triggered, they call setState on it. You have no guarantee that the execution of the React rendering will be synchronous to your action dispatching. It may work in your simple example but will not in more advanced ones unless react-redux's connect permits to know when all underlying components have finished to render (ie listener to this.setState's callback).

See also reduxjs/react-redux#269 (comment)

@AvraamMavridis
Copy link
Owner

@slorber Thx, I will have a look at it. Probably you are right, if your state contains DOM related info and the rendering hasnt finish the middleware will not measure correct. But, just out of curiosity, why to hold inside your state the actual DOM info and not a description of it that React could use to build the DOM again if needed?

@slorber
Copy link
Author

slorber commented Jan 29, 2016

Uhhh? Where did I say that I hold DOM info inside the state? I have a perfectly reasonable usage of Redux that do not do such a thing.

When you use connect of Redux it builds a React component that calls this.setState when your selectors data changes. setState takes a callback so that we can know when rendering has ended (check React doc). connect does not use this callback (yet) so you can't know fore sure when the React rendering has ended, even if it works fine in your simple usecases.

@AvraamMavridis
Copy link
Owner

@slorber I see the issue, but I dont see how it can be fixed in the context of this middleware if redux is not using the setState's callback. If you have a proposal, I am glad to hear or accept any PR.

@slorber
Copy link
Author

slorber commented Jan 29, 2016

@AvraamMavridis I don't expect you to do anything, it must be solved by connect first that's why I pointed to an existing react-redux issue

@AvraamMavridis
Copy link
Owner

cool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants