Last week Hooks were finally added to React. It is now possible to use state in a function. At least, that much I remembered from watching the init...
For further actions, you may consider blocking this person and/or reporting abuse
Am I the only person think useEffect is cool but hard to read?
people who new to Reactjs will really confuse with the setup
since "useEffect" doesn't tell anything on its name but "componentDidUpdate" definitely tells when the function will be called
Also, the unmount function part is hard to read
I think it should replace HOC, but not for middle size component(like your example)
Yes, the naming isn't optimal, I think.
useState
is pretty straight-forward, butuseEffect
not so much.On the other hand, they are basic building blocks used to create more sophisticated hooks that would have clearer names.
useFetch
,useHttp
,useTrackingApi
,useFacebookLogin
etc.functional component is not as organized as a class component
Giving the power of state is great, but ppl(lots of programmers) usually abuse it
what if your component has react.memo + useEffect + useState inside and outside a function? really a pain in the ass to a new react programmer.
Will definitely lower the intention of ppl learning react
I kind of agree with you Mark. I think hooks are really powerful, which makes them easy to abuse. An 'experienced' React programmer can make components unnecessarily complex just to be 'smart'.
And like you say, that would be a huge pain for beginners. The class structure is much easier to read in that sense. But having used React for a bit longer now, I do appreciate what hooks allow you to do. You really feel more in charge of your components and logic.
I guess with great power comes great responsibility :)
Hey Radu! Thanks for the feedback. To be honest, I was quite unaware of this, but thinking about it, it actually makes sense :)
I've updated the code! Thanks again :)