-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Introducing functional components #1032
Conversation
Huh build failed. Worked on my machine 🤔 |
Oh right wasm-pack is missing from the build server, but I'm using it to run the tests |
Another question comes to mind: Should the firing of use_effect cause the component to rerender? It currently does but in retrospect i don't think it should. Instead the setstate method called inside use_effect is what should be causing a rerender. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks for taking on this proposal, I cannot wait to use it in my project :D
I'm really excited about adding context hooks in the future as well, it will ease a lot of state management headaches.
I have a concern over the restrictiveness of hook ordering.. it's a runtime check unfortunately. So if anyone wraps a hook in a conditional they will get panics. But maybe React has this problem too? I'm curious your thoughts on it.
In regards to use_effect
, do you think it should be called after the component is mounted? Maybe promise wrapping it would do the trick.
Thanks again!
@jstarry Alright use_effect is now refactored to run on next tick 👍 |
Hey, I really think this PR should be split. Use effect still needs work and will likely need some core framework changes. Can you remove all use effect code so that we have the foundation in place earlier and then can iterate on use effect implementation? |
If you insist I can remove it of course, but I honestly think use_effect is too essential to skip it :/ |
Also I've removed next_tick and replaced it by making message a Box<FnOnce() -> bool>. This does indeed now rely on the framework to batch renders. |
Not remove, just move |
I like to give detailed reviews on smaller PRs. This change is already pretty big and hard to keep up with what has changed since the last time I viewed |
Ah I see, sorry |
Alright. use_effect is out 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for splitting out the use_effect code temporarily! It's fine to keep the commented out tests. As soon as you address my last few comments, we can merge this in and work on getting use_effect
in!
Nice solution! And thanks for writing up #1034! |
Yw :) |
Thanks for the cleanup! |
You're welcome, I appreciate your dedication to the PR and having everything orderly :) |
Details in proposal #1026
I think the two main questions are whether the use_effect hook should always run if no arguments are supplied or always, and if FunctionProvider and FunctionComponent are appropriate names