2 ms·
Just use a global object and continuously run setState on the root component inside a requestAnimationFrame. Whenever you need to use or display something just
by Kiro 4y ago
Just use a global object and continuously run setState on the root component inside a requestAnimationFrame. Whenever you need to use or display something just reference or set the global object and you will be sure it's visually updated within the next rAF.
- zenosmosis 4y agoI'm not sure if this was a serious comment, but that sounds like a massive amount of performance overhead. A way to optimize that approach substantially, while keeping everything else mostly the same, would be to have a setter on the global object, and only re-render the root component when that setter has updated the state. My suggestion is not a very optimal approach, but probably a lot better than the continuous state loop.