by baron816 · 6y ago · 0 comments
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.
This is really interesting! Great idea.
I've been able to notice performance hiccups in these cases even just using React state. Of course debouncing usually helps.