Show HN: Legend-State 1.0 – The fastest React state library
legendapp.com
I'd love to know what you think, and I'm also happy to answer any general JavaScript performance questions if you want since I've gone very deep into optimizing .
legendapp.com
I'd love to know what you think, and I'm also happy to answer any general JavaScript performance questions if you want since I've gone very deep into optimizing .
- I've seen huge React components with tons of useState, so every little state change re-renders a massive component with lots of complex logic. It can be better to split that into subcomponents so it renders less, less often. - In React, it's usually good to wrap components in memo. Without memo, any state change passes down the entire component tree, and then the virtual dom has to diff a massive tree of nodes, which is slow. - Chaining array functions like map and filter can be slow because it loops the full array and also allocates a new array for each one. If you're doing multiple operations on an array it's probably better to use a simple for loop with your complex logic, and push to an "out" array.
If you want to go deep on micro-optimizing, these are some of the little differences we've found. I think we will expand on this with some benchmarks. https://legendapp.com/open-source/state/fast/#micro-optimiza...
And if you want to go deep on React performance and what Legend-State does to make it faster, I went into a lot of detail here: https://legendapp.com/open-source/legend-state/