Skip to content
Discussion options

You must be logged in to vote

But obviously this doesn't exist.

Well, it could exist, but the PR for it is stuck in limbo.

Meanwhile, you would usually use an $effect for that.

$effect(() => {
    localStorage.setItem(key, JSON.stringify([...ignoredRepos]));
});

As long as you read the object deeply (which JSON.stringify does), the effect will trigger on any change to the object.

(Note that the $effect will trigger at least once on component mount. So if e.g. the ignoredRepos state is invalid at that point, you might have to guard against that. Note that the guard condition has to be stateful as well, otherwise the $effect will not rerun once the condition changes.)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@KieranP
Comment options

@webJose
Comment options

@brunnerh
Comment options

Answer selected by KieranP
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