6 ms·
I don’t thinks hooks are a great example. Hooks are by definition effectful. Best compared to ‘Applicative’s in Haskell. (Not monadic unfortunately) So a funct
by sfvisser 6y ago
I don’t thinks hooks are a great example. Hooks are by definition effectful. Best compared to ‘Applicative’s in Haskell. (Not monadic unfortunately)
So a functional component in react using hooks is not pure. You can translate it into FP with a bit of magic, but requires a context. The line is not that distinct at all.
- Jestar342 6y agoHooks themselves may not be good FP examples, however I meant the resultant functional components that you develop yourself usually are.
- snarkypixel 6y agoHooks are implicitly injecting whatever global state in your stateless components, so definitely not a good example of functional concepts imho.