You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I'm trying to pass a state as dependency for a callback function, this state is a vector of struct, I get no compiler error, but the callback never update when the vector state is mutated.
Am I doing something wrong or is there a workaround to this problem?
thanks for your help.
let messages_handler: yew::UseStateHandle<Vec<Message>> = use_state(|| {
vec![]
});
let messages_handler_value = (*messages_handler).clone();
let on_new_message: Callback<Message, ()> = {
let messages_handler = messages_handler.clone();
let messages_handler_value = messages_handler_value.clone();
use_callback(
move |message: Message, messages_handler_value| {
let mut messages_handler_value = messages_handler_value.clone();
messages_handler_value.push(message);
messages_handler.set(messages_handler_value);
},
messages_handler_value.clone(),
)
};
The text was updated successfully, but these errors were encountered:
Is this actually a bug? I think what happened here is that the line
let messages_handler_value = (*messages_handle).clone();
defines not a state handle, but a Vec, you've simply cloned the inner vector so there's no longer any association of it with the handle.
I'd consider closing this issue.
Hi,
I'm trying to pass a state as dependency for a callback function, this state is a vector of struct, I get no compiler error, but the callback never update when the vector state is mutated.
Am I doing something wrong or is there a workaround to this problem?
thanks for your help.
The text was updated successfully, but these errors were encountered: