- [ReactN useGlobal can fire even if the reference does not change. In other words, if the entire object is passed to setGlobal, all hooks will be triggered and redrawn. After thinking for a while about how to deal with it, I realized that passing the entire object is a case of making a destructive update by creating a whole draft in immer, so I changed my own utility function updateGlobal for that purpose to a “make change diff and update” mechanism.
before ts
after ts
before / after A simple mousedown that took 120ms to redraw the entire screen is now only 4.8ms for the necessary part.
This page is auto-translated from /nishio/変更差分を作ってsetGlobalする using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.