Subscribe to array/item in array? #849
Answered
by
dai-shi
piscopancer
asked this question in
Q&A
-
Let's say I have a component that should track the name in the store it was given in props const namesStore = proxy({
names: [] as string[],
})
function NameFinderComponent({name} : {name: string}) {
const nameSnap = useSnapshot(namesStore.names.find((s) => s === name) /** can be undefined */)
return nameSnap ? 'such name exists' : null
} However the name can be not found, leading to inability to subscribe to it. I would probably have to subscribe to array then, right? |
Beta Was this translation helpful? Give feedback.
Answered by
dai-shi
Jan 29, 2024
Replies: 1 comment
-
Yes. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
piscopancer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes.