4 ms·
Being explicit about effects does not make the function pure, does it? Why claim FP credentials if all or most of your functions are going to be impure?
by interlocutor 5y ago
Being explicit about effects does not make the function pure, does it? Why claim FP credentials if all or most of your functions are going to be impure?
- dclowd9901 5y agoI’m not sure the react team ever makes such a claim. Indeed, the only claim of strict FP I could find in the docs comes by way of this quote: “ All React components must act like pure functions with respect to their props.” Which they do. You cannot and must not mutate props. There are of course ways around this (JavaScript being JavaScript) by, say, passing a useRef defined constant down and then updating its “current” field, but that’s completely on you.
- flowerlad 5y ago> I’m not sure the react team ever makes such a claim How about this quote: "Finally, if you’re a functional programming purist and feel uneasy about React relying on mutable state as an implementation detail, you might find it satisfactory that handling Hooks could be implemented in a pure way using algebraic effects (if JavaScript supported them)." That sure sounds like they are saying even FP purists should feel comfortable using hooks. See https://medium.com/@dan_abramov/making-sense-of-react-hooks-fdbde8803889 https://medium.com/@dan_abramov/making-sense-of-react-hooks-...