top | item 26134705

(no title)

Jestar342 | 5 years ago

Likewise most of the hooks (useReducer being the obvious primary example), and functional components in general. That's how 99% of functional programming is done - state and function are separate, first class, concepts. The line is very distinct.

discuss

order

sfvisser|5 years 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|5 years ago

Hooks themselves may not be good FP examples, however I meant the resultant functional components that you develop yourself usually are.