Replies: 1 comment 1 reply
-
That just sounds like bandied over a bigger issue, components being unaware of their lifetime which requires callbacks to be In the meantime, I wouldn't mind implementing this macro if it's desired. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
One pain point when using functional components is cloning all the
Rc
s into callbacks/closures.For example, just by looking at the documentation here https://yew.rs/docs/en/next/concepts/function-components/pre-defined-hooks#use_state,
counter
is first cloned in a separate scope.This is very unergonomic and adds an additional indentation level.
In my own projects, I use the enclose crate but it doesn't seem to be mature/popular enough to official recommend it.
I propose adding a simple macro called
callback!
orcb!
built intoyew_functional
that provides similar functionality. Since this could be specifically tailored for functional components, we could even automatically wrap the closure in aCallback
. This would also partially solve issue #1657.Beta Was this translation helpful? Give feedback.
All reactions