Comment

Comment by baron816

If you want a really frictionless state management library for React, please try out my library https://github.com/baron816/use-structure

It lets you make state updates using native JavaScript mutation APIs. It uses Proxies to convert those mutable updates to be immutable so that your component updates correctly. This will work:

...

const arr = useStructure([]);

...

<button onClick={() => arr.push(1, 2, 3) }>Add value</button>

But you could use deeply nested arrays/objects/Maps/Sets. Or you could use your own class with its “mutating” methods.

If you know basic JS, you should be able to use it without worries.

parent baron816 6 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton