-
The new leptos 0.7 release notes recommends using channels to send views rather than storing views in signals which was previously possible in 0.6. However, I'm running into problem where the context is unavailable to views sent through a channel. Here is a minimal example of what I'm trying to accomplish:
The first view that is received on the channel is able to access the context, however any subsequent views received are unable to access the context. I've considered the alternative of manually sending props to any element sent through a channel, however my application depends a lot on the context api, this would result in significant restructuring... Am I missing something obvious? Any help would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The problem here is mostly just that context isn't available in event handlers, I think. The short answer: Use |
Beta Was this translation helpful? Give feedback.
The problem here is mostly just that context isn't available in event handlers, I think.
The short answer: Use
Owner::current()
to get the current owner at some point (i.e., in the body of theSendsMessage
component, and useowner.with(|| { ... })
orOwnedView::new_with_owner
to set it as the owner for the view you're sending through the channel.