DEV Community

Discussion on: Can React state management get any simpler than this?

avkonst profile image
Andrey • Edited

Yes, it can get simpler, and it also needs to be more scalable and more powerful. Have a look at the Hookstate. It is as simple as React.useState API. It is hard to get any simpler than this, but at the same time Hookstate supports most (if not all) of state management needs, has got very impressive performance (Recoil, try to beat this: and can be extended with custom plugins when needed. (Disclaimer, I am an author of the project)

robvirtuoso profile image
robvirtuoso • Edited

So I see this kind of post again from the proud author of HookState, making comparisons as if it is a competition of who makes the best library.

Have you even tried these libraries being discussed in posts that you are hijacking? In this particular case you just enumerated what the library already does, as if they are missing in the library... so I guess you didn't bother to look.

I did stumble upon HookState earlier this year, and found that it overrides useState (by using the same name), and then changes its construct altogether, uses inconsistent parameter semantics for global vs. local usage, and on top of that, introduces a different output type for async state while using the same useState construct (talk about unpredictability!). Why would you do that??? After that, I looked elsewhere sorry.

(See, even if I am personally biased towards a different library, I didn't even feel the need to compare. I just objectively say why I didn't pick up HookState.)

Dude, one piece of unsolicited advice, stop promoting your own library in discussions that talk about another library. It is quite distasteful, and just brings a bad impression on your library to be honest.

avkonst profile image
Andrey • Edited

No, I expressed my opinion on the asked question if it can be any simpler.

"so I guess you didn't bother to look."
I looked at this.

"Why would you do that (use the same function name)???"
Because whatever the argument is, it gives you back the State object, which has got the same functionality regardless if a state variable comes from local variable, global variable, if it is a Promise or not.

" it overrides useState"
It does not override it. It just have got the same name because it does the same (for the case of the local state). If it is no-no, there is an alternative name 'useHookstate' or you can name alias on import or you can use module prefixes.

"different output type for async state"
No, you are not right with this statement. It is still an object of the same type with the same API and functionality.

"After that, I looked elsewhere sorry."
Good on you. I am quite glad you moved.

"I just objectively say why I didn't pick up HookState."
I got you objection comments on board. Thanks
Here is another view on Hookstate by someone else, who actually see it valuable:

"stop promoting your own library in discussions that talk about another library"
Thanks for the advise. I hope you will take the effort to put down similar promotions everywhere around the internet? or maybe start with this article...
People pointing out to so many other alternatives all over the place. Many people said me "Thank you for the awesome library" after going to it from a "promotion" comment like this. So, I guess if there were no "promotional" comments people would not discover it and some of them would not get the tool which solves a real problem for them and makes them happy. I guess if I had a twitter account with millions of subscribers like some other "more well known" libraries use, I would not need to comment anywhere or even pay attention to comments like yours. At the same time I am a developer and prefer to write code, instead of developing marketing presence and twitter accounts. The tool I published solved a problem for me (no other state management library, I am aware of, solves the problem of performance of frequent deeply nested large state updates). I published it with the hope it makes life easier for somebody else too. And it did. I appreciate many will not bother even to look at it, because it does not come from Facebook or alike. But a few will and do use it, and it is enough.

Thread Thread
robvirtuoso profile image
robvirtuoso • Edited

I thought it prudent to repost here what I wrote in response to another conversation with you elsewhere... so that I may be completely fair to you. I do appreciate the effort you put into your library and for maintaining a good demeanor despite criticism.

---- Repost starting from here ---

I'm not trying to antagonize you. I just hate the idea that independent open source contributors like you will get a bad reputation due to their posts like this. I find publishing open source libs a noble thing to do, especially for people who don't earn a dime from it. You seem like you belong to this category, so I appreciate your efforts. I actually help promote work of libs that I personally use, as a way of giving back to the author/maintainer. If your posts triggered a bad reaction from me, it may happen with others too. So again I wouldn't wish you that misfortune.

You may not be asking for advice from me, but if it was me I would not want people thinking that I'm doing this to compete with the big guys (Redux, Recoil, etc.) which are backed by a big corporation and fanboys... And nor would I ever say that my lib is superior to another , popular or new one.... open source is not a popularity contest after all. As long as a number of people actually use your library, i.e. it is helping some folks out there, it means you already are doing a good job.