If I'm using an async redux library along with reselect, is there a definitive pattern for performing a selection in mapStateToProps when the state object being "selected" depends on the completion of the async action?
I'm using the following solution, but it seems inelegant...
const mapStateToProps = (state) => {
if (state.roles.list.length) {
return {
role: selectRole(state),
permissions: selectPermissions(state)
}
} else {
return {}
}
}
class MyComponent extends React.Component {
componentDidMount() {
this.props.dispatch(getAllRolesAndPermissions());
}
...
}
connect(mapStateToProps)(MyComponent)
How can I perform "selections" with reselect
library on state that depends on async actions to populate the state?