Re:Common Beginner Mistakes with React
by LudwigNagasena on Saturday March 11, 2023 @07:31PM
(#35114732)
Any function is a pure function if your consider the entire program state as your input and output.
[ Parent
| on HN ]
Re:Common Beginner Mistakes with React
by satvikpendem on Saturday March 11, 2023 @07:55PM
(#35114966)
I see you've discovered the IO monad in Haskell.
Re:Common Beginner Mistakes with React
by bayesian_horse on Monday March 13, 2023 @04:58AM
(#35132973)
You really don't need to give hooks access to some global variables (or all of them). You can, of course. But you would actually do that in a useEffect or use some setState in a callback somewhere.
It's a cheap shot to complain that Javascript isn't a purely functional language... React can be used in a pretty pure way and if you don't you'll don't get the full benefit.