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

setState #13

Open
blocka opened this issue Jul 30, 2017 · 2 comments
Open

setState #13

blocka opened this issue Jul 30, 2017 · 2 comments

Comments

@blocka
Copy link

blocka commented Jul 30, 2017

Current behavior is a naive conversion between this.setState and this.*.
setState is more complicated then this, however.

  1. It takes a second argument which is a callback when the setState has been applied.
  2. It can take a function which takes the previous and current props and returns the next state.

Also in general the semantics are not 100% similar. If I'm not mistaken, this.setState doesn't even mutate the state right away, while obviously this.* does, just that the DOM updates get batched. I have no idea if this difference will be a cause of bugs...I guess time and lot's of testing will tell.

@blocka
Copy link
Author

blocka commented Jul 30, 2017

And of course forgot to mention that react doesn't require the state be declared up front like in vue.

@nickmessing
Copy link
Member

@blocka, you're right, we'll increase the transpilation success rate with time but obviously it's impossible to make 100% compilant converter, however, if you could provide few examples where it's wrong we would be able to at least cover that cases, I'll try to implement setState callback for now.

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