Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Show HN: Legend-State 1.0 – The fastest React state library (legendapp.com)
5 points by jmeistrich on May 15, 2023 | hide | past | favorite | 2 comments
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 .

https://github.com/LegendApp/legend-state



What are some the popular patterns to avoid in javascript that get you good performance? Or phrased another way, what are the changes to make today that would likely have the most performance impact in a js codebase?


A few examples I can think of:

- 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/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: