Replies: 1 comment
-
In our context, optimization refers to render optimization, which is to avoid extra re-renders. It's not about optimization in general.
It's probably because it subscribes the whole state and doesn't track usage.
Using valtio/docs/how-tos/how-to-avoid-rerenders-manually.mdx Lines 18 to 27 in 3c92092 |
Beta Was this translation helpful? Give feedback.
-
I've come across a couple of issues with the README in the useSnapshot() section, which is, of course, an essential section for the use of Valtio.
There's a comment in the code sample that reads:
However, there is no
state.text
in the actual example. Should this be fixed?The other issue I've found is with:
It later talks about using
snap
for optimization. However, if I just use the originalstate
object, rendering is actually going faster for me in a small and stupid test I made up just to play with Valtio. It can be found at https://codesandbox.io/s/adoring-cori-mcv7ow?file=/src/App.js:970-985. Changing references fromsnap
tostate
in theApp()
function makes the app appear to run about 20% faster on my computer. Doesn't make any real world difference, I just found it interesting and opposite of what the README says to do. Are there some places that one should usesnap
and others one should usestate
in the render process?Beta Was this translation helpful? Give feedback.
All reactions