YousefED / SyncedStore

SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.

Home Page:https://syncedstore.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

set whole object on useSyncedStore

UXDart opened this issue · comments

hi! if I have "const params = useSyncedStore(store.data.params)" and I have a store that has { data: { params: {} } as ISomeInterface }
imagine I want to set params to a new object, I can't do params = newParams;. I need to do useSyncedStore(store.data) and then do data.params = newParams

the problem is that because I'm observing store.data, it will refresh on any update. if I observe store.data.params, how do I set params to newParams?

TIA

oh... can someone confirm this, if I do const storeData = useSyncedStore(store.data) / it will trigger a refresh only where I'm using storeData.abc... then only if abc changes it will trigger the refresh? it is smart the way it refreshes? thanks

oh... can someone confirm this, if I do const storeData = useSyncedStore(store.data) / it will trigger a refresh only where I'm using storeData.abc... then only if abc changes it will trigger the refresh? it is smart the way it refreshes? thanks

That's correct! Also see https://syncedstore.org/docs/react#usesyncedstore-hook