Make more use of selectors
Motivation
- Using selector functions to access the state helps with code reuse
- Well designed selectors can be composed in ways that make refactoring much easier
- Selectors are pure and easy to test
- Container components are hard to test and benefit from being kept small and logic free
Approach
- Create selectors for each atom of state access:
selectFragments
, selectVersions
, selectLatestVersion
...
- There is already an
xpub-selectors
package
- I fear this will not scale when it comes to having multiple xpub implementations
- However organisation of selectors is a particularly hard (unsolved?) problem and I don't have a better suggestion
- Update all instances of
mapStateToProps
to use selectors instead of directly accessing the state
- Use Reselect which is a popular library for composing selectors which also brings some performance benefits