Done a little investigation on this on my own time & just wanted to add the following from my reading:
- react hooks are a way for functional components (ie non-class components) to use state. Prior to introduction of git hooks in react 16.8:
- functional components could only use props, not state
- For a component to use state required a class component
- redux
- using react hooks would appear to be a decent solution to store local state of a component but does not seem to replace the need for a global state management library like redux
- functional vs class components
- we primarily use class components in the mobile-security-service ui
- we do not distinguish containers vs components by using classes for the former and functional components for the latter
- it is not clear what compelling reasons there are to use functional components over class components. The react team allude to potential future performance boosts from functional components, but it would need to be verified if these boosts have been implemented.
- react team have claimed they have no plans to deprecate the use of classes, so there is no pressure to switch from classes to functional components
- its unclear (to me) if functional components can be connected to redux and whether we can completely replace classes in our repo with functional stateful components
React hooks seem a good solution to add state to functional components to manage the components local state. It does not seem adoption of react hooks would have substantial implications for our existing architecture, but further investigation may be required. |