4 ms·
Perhaps someone that knows more about hooks can help me to understand the trade-offs. After looking at the intro: https://reactjs.org/docs/hooks-overview.html
by diegof79 8y ago
Perhaps someone that knows more about hooks can help me to understand the trade-offs.
After looking at the intro: https://reactjs.org/docs/hooks-overview.html https://reactjs.org/docs/hooks-overview.html
My understanding is that each time that you call useState the renderer is keeping track of a state associated with the currently rendered component.
It’s a clever solution, but that implicit context bothers me a little bit.
For comparison, Flutter makes the state relationship explicit: https://docs.flutter.io/flutter/widgets/StatefulWidget-class.html https://docs.flutter.io/flutter/widgets/StatefulWidget-class...
The Flutter approach is more verbose, and I don’t know if I like it or not. But the useState looks like a maintenance nightmare. There is no way to type that function usage correctly, and the dependency is not explicit (making refactoring and testing cumbersome).
Any experiences to share?