`useAtomCallback` creates a lot of atoms, resulting in performance issues
See original GitHub issueuseAtomCallback
dynamically creates an atom whenever it is called, once per call site. Because of that, code with a number of components, where each component uses just a couple of callbacks, can result in a very large number of atoms being created. This appears to have a serious impact on performance.
I made a recording where I show the extent of the problem (sorry for crappy quality, I had to compress it because it was too big for Github). I also have a link to the Codesandbox I used.
https://codesandbox.io/s/demonstration-of-useatomcallback-performance-issues-29qtj?file=/src/App.tsx.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
useAtomCallback not compatible with async atoms #1345
Attempting to read async atom within useAtomCallback results in a promise being thrown: ...
Read more >`useAtomCallback` creates a lot of atoms, resulting in ...
useAtomCallback ` creates a lot of atoms, resulting in performance issues. ... couple of callbacks, can result in a very large number of...
Read more >useAtomCallback - Jotai
It takes a callback function that works like atom write function, and returns a function that returns a promise. The callback to pass...
Read more >Demonstration of useAtomCallback performance issues
Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
Read more >Reagent performance issue when passing atom as a function ...
re-frame/dispatch puts your events in a queue for re-frame to process, so there can be a slightly delay before it actually goes through...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dai-shi I will try to investigate the cause of the slowness, but can’t make any specific promises right now, because I’m fairly busy with stuff. 🙁 Thank you for your work on this library, it’s very nice.
Not sure I see the issue tbh - It’s correct that
useAtomCallback
comes with a cost, because it’s additional code. It’s a way to interact with atoms imperatively.@papermana, Can you just not use it or lift the state up, so you have the
useAtomCallback
in the parent component?