Skip to content

how to derive a deeply reactive variable from another? #16187

Answered by brunnerh
aster-void asked this question in Q&A
Discussion options

You must be logged in to vote

As has been mentioned in #16189, one can wrap the value in a $state proxy to get deep reactivity in derived values.

$derived.by(() => {
    let val = $state(...);
    return val;
});
function proxify(value) {
    const proxified = $state(value);
    return proxified;
}

let foo = $derived(proxify(...));

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@aster-void
Comment options

@peterreeves
Comment options

@aster-void
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by aster-void
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants