r/reactjs • • Oct 17 '26

React state hooks are footguns

If you take software engineering principles seriously then none of the react state hooks belong inside a react component.

I think one of the most critical things you should do is ensure the decoupling of storage and UI components. The react components force you to do is precisely and zustand doesn't help.

I haven't sourced grip-react a year ago and I've been using it exclusively, absolutely zero usestate usememo, useeffect, etc and absolutely zero prop drilling. I don't know why anyone would want to do something different, honestly.

Has anyone else created an API that is a 100% replacement with complete declarativeness? I looked at angular and mobx, they're close but no cigar.

0 Upvotes

13 comments sorted by

1

u/Top_Bumblebee_7762 Oct 17 '26

useState seem unavoidable (unless you use useReducer instead everywhere) in any react app. 

1

u/GianniMariani Oct 18 '26

https://owebeeone.github.io/grip-sudoku/ - Avoids useState. Plenty more demos where that came from - here is a test that explicitly disallows it just to point it out in the sudoku example - https://github.com/owebeeone/grip-sudoku/blob/main/scripts/no-react-state.test.mjs

3

u/TheChickenKingHS Oct 17 '26

I’m not sure if this is a misunderstanding of a functional component, a ui component or JSX as a concept and I’m just curious as to which…

1

u/[deleted] Oct 17 '26

[removed] — view removed comment

1

u/TheChickenKingHS Oct 17 '26

Sometimes I use a ref on the ui element, instead of creating an entire UI component. I think now that the react compiler is here a refs are automatically forwarded it will be a bit more common but I do tend to try to start with a UI element with props fully exposed before upgrading into a component. 

3

u/rafark Oct 17 '26

Principles and good practices evolve. I’m not saying react is perfect but after some time you realize software can have many valid forms

2

u/azangru Oct 17 '26

If you take software engineering principles seriously then none of the react state hooks belong inside a react component.

Why are you using this horrible library then, if it creates so many footguns?

I haven't sourced grip-react a year ago

You haven't?

2

u/_Feyton_ Oct 17 '26

Just use vanila JS at that point bro, don't let the bundler limit you king🙏🙏🙏

0

u/[deleted] Oct 17 '26

[deleted] — view deleted comment

2

u/musHeaer Oct 18 '26

seconding this, would love to see how it holds up in something non-trivial

1

u/GianniMariani Oct 18 '26

I have a number of non-trivial apps above and beyond the examples in my reply to u/is-undefined - the point is the dataflow/context graph and my next trick is to push the graph down into the server - very close but not there quite yet. Full reactive backend to frontend over a p2p infrastructure - infinitely scaleable.

1

u/GianniMariani Oct 18 '26

https://owebeeone.github.io/grip-react-demo/
https://owebeeone.github.io/anchorscad-browser/
https://owebeeone.github.io/grip-sudoku/ (demo login - nothing stored on server - it's just an example)
https://github.com/owebeeone/jowna#examples

plus many more - it works very well with a "plugin" architecture too - I have another 4 projects using that - not ready for demos but soon.