How to create complex trees of dependencies with jotai? #2754
Replies: 4 comments 13 replies
-
Thanks for reporting. I wonder where's the bottleneck. Would anyone like to dive into it? |
Beta Was this translation helpful? Give feedback.
-
Is #2334 related? |
Beta Was this translation helpful? Give feedback.
-
I don't think it's the number of atoms that's the problem, but rather the function creating the atoms. I managed to get 31 to work but I do have to click "wait" when the page is reported as unresponsive. |
Beta Was this translation helpful? Give feedback.
-
I got 3000. Is this cheating? https://stackblitz.com/edit/vitejs-vite-pvkhtl?file=src%2FApp.tsx |
Beta Was this translation helpful? Give feedback.
-
I'm trying to perform a spike using Jotai for creating large trees of derived values.
Spike/Benchmark
Cells of each next layer are calculated from the previous layer cells + the value of the current cell. Clicking on cell increments its value and should update all the dependants.
A2 Derived=A2+B1
B2 Derived=B2+A1-C1
C2 Derived=C2+B1+D1
D2 Derived=D2+C1
It's based on this benchmark for reactive computations: https://github.com/Riim/cellx?tab=readme-ov-file#benchmark
This is what it looks like:
jotai_tree.mp4
https://stackblitz.com/edit/vitejs-vite-szeeg9?file=src%2FApp.tsx,src%2Findex.css&terminal=dev
Issue
I cannot go to up to 30 layers with jotai. Creating the tree just freezes the page on initial load. I'm a jotai newbie so I might be missing something obvious in the documentation.
Beta Was this translation helpful? Give feedback.
All reactions