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

Return a promise from setState #41

Closed
anthonyshort opened this issue Jan 27, 2015 · 4 comments
Closed

Return a promise from setState #41

anthonyshort opened this issue Jan 27, 2015 · 4 comments

Comments

@anthonyshort
Copy link
Owner

This shouldn't be too hard. Just return a promise and resolve it on an event.

@anthonyshort
Copy link
Owner Author

I think we might just remove the callback from setState. Almost every use-case can be covered in afterUpdate. I can't think of anything that would benefit from it.

@yoshuawuyts
Copy link
Contributor

agreed. if afterUpdate is the only thing that's triggered, well, after an update it makes for more transparent code. That also means there's no need to return a Promise.

@ivan-kleshnin
Copy link

@anthonyshort did you consider to make setState actually synchronous?
I mean to make it represent pending state and not rendered state.
It was discussed in React community many times https://groups.google.com/forum/#!msg/reactjs/R61kPjs-yXE/bk5AGv78RYAJ
but everything stucked because of backward compatibility issues.

I think your project is comparatively free to fix this design issue.
Hooks are mess and do not cover every usecase.

@anthonyshort
Copy link
Owner Author

@ivan-kleshnin We're definitely more free to make changes like this. In general I don't like the hooks, and I've found we rarely use them anyway. The only one I can see being useful would be something like afterRender so you could update some canvas element using the latest state.

I'm not sure I'm following the exact reasoning behind it yet though. What are the benefits to it? We don't access state on this so it probably wouldn't update the state object that gets passed in anyway.

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

Successfully merging a pull request may close this issue.

3 participants