4 ms·
Nothing is simpler than a function. Easier to write, debug, and test. * Removed "pure" to make my main point clear.
by s_y_n_t_a_x 7y ago
Nothing is simpler than a function. Easier to write, debug, and test.
* Removed "pure" to make my main point clear.
- RussianCow 7y agoBut functions that use hooks aren't pure because hooks break referential transparency.
- istoica 7y agoHow are your functions pure if inside them you call `useEffect`, `useState` ? Where is pureness when at first look they generate side effects, or am I missing something ?
- s_y_n_t_a_x 7y agoNot all functions needs hooks, not all hooks break pureness. But my point was functions are simpler in all those scenarios, pure or not. Edited my comment to reflect that.
- csande17 7y ago> not all hooks break pureness Sure, if you define a function called useWhatever that doesn't actually call any hooks, that might be a pure function. But the restrictions described in https://reactjs.org/docs/hooks-rules.html https://reactjs.org/docs/hooks-rules.html are not restrictions that pure functions have.
- shantly 7y agoSimplicity does not necessarily imply clarity.