You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, why would I want this?
Answer:
Deep Nested reactivity like mobx
Want to construct complex class trees at runtime
Want to pass reactive objects into deeply nested UI ( avoid passing both proxy and snapshot into every component )
Want reactivity to survive useSnapshot()
import{proxy}from'valtio'classMyViewModel{prop1: stringproxy?: MyViewModelconstructor(){this.prop1='Some String'//Make MobX style reactive, proxy will survive map, for() useSnapshot etcif(typeof(window)!=='undefined'){//Only do this client sideconstprox=proxy(this)this.proxy=ref(prox)returnprox}}updateProp(){(this.proxy??this).prop1='Some Other String'}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First, why would I want this?
Answer:
Deep Nested reactivity like mobx
Want to construct complex class trees at runtime
Want to pass reactive objects into deeply nested UI ( avoid passing both proxy and snapshot into every component )
Want reactivity to survive useSnapshot()
Beta Was this translation helpful? Give feedback.
All reactions