Show HN: Legend-State 1.0 – The fastest React state library (legendapp.com)
After almost a year of development and iterating, we just released Legend-State 1.0. It's the fastest React state library and is very easy to use, based on Observables (Signals) with fine-grained reactivity and built-in persistence.
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 .
2 comments
[ 4.0 ms ] story [ 16.1 ms ] thread- 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/