Valtio needs something that allows users to put non proxied data into the store. Currently it cannot handle foreign classes and objects, since accessors to parents/children end up proxying the entire system because Valtio cannot differentiate and just climbs through the nested graph. This is shaping up to be a bigger concern because right now it can only hold serializable data.
A suggestion would be to introduce some kind of hint that makes it only check reference equality if the users wants it so.
import { proxy, ref } from 'valtio'
const state = proxy({
status: true,
city: 'Berlin',
body: ref(document.body), // < will not be proxied
audio: ref(new Audio('/hello.mp3')), // < will not be proxied
})
// I guess it needs to be consistent, so overwrites probably need it, too ...
<div onClick={() => state.audio = ref(new Audo('/chime.mp3'))} />
This wouldn't work with SSR or localCache, but at least we have the ability to throw complex foreign state into the store in local scenarios.
Valtio needs something that allows users to put non proxied data into the store. Currently it cannot handle foreign classes and objects, since accessors to parents/children end up proxying the entire system because Valtio cannot differentiate and just climbs through the nested graph. This is shaping up to be a bigger concern because right now it can only hold serializable data.
A suggestion would be to introduce some kind of hint that makes it only check reference equality if the users wants it so.
This wouldn't work with SSR or localCache, but at least we have the ability to throw complex foreign state into the store in local scenarios.