mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 14:54:16 +00:00
fix: panic when creating nested StoredValue
(#920)
This commit is contained in:
parent
f919127a7e
commit
e5d657dd55
1 changed files with 5 additions and 2 deletions
|
@ -191,8 +191,10 @@ impl<T> StoredValue<T> {
|
|||
/// the signal is still valid. [`None`] otherwise.
|
||||
pub fn try_with_value<O>(&self, f: impl FnOnce(&T) -> O) -> Option<O> {
|
||||
with_runtime(self.runtime, |runtime| {
|
||||
let values = runtime.stored_values.borrow();
|
||||
let value = values.get(self.id)?;
|
||||
let value = {
|
||||
let values = runtime.stored_values.borrow();
|
||||
values.get(self.id)?.clone()
|
||||
};
|
||||
let value = value.borrow();
|
||||
let value = value.downcast_ref::<T>()?;
|
||||
Some(f(value))
|
||||
|
@ -407,6 +409,7 @@ impl<T> StoredValue<T> {
|
|||
/// let callback_b = move || data.with(|data| data.value == "b");
|
||||
/// # }).dispose();
|
||||
/// ```
|
||||
#[track_caller]
|
||||
pub fn store_value<T>(cx: Scope, value: T) -> StoredValue<T>
|
||||
where
|
||||
T: 'static,
|
||||
|
|
Loading…
Reference in a new issue