After some tests, I realized that it works very well. Recompose rocks to create with clean components.
It works great and works very well.
const enhWithHandlers = withHandlers({
loginUserMutation: props => args => {
props.updateMutationState(loading: true, error: null });
props.loginUser(args)
.then(() =>
props.updateMutationState({loading: false, error: null }))
.catch(err =>
props.updateMutationState({ loading: false, error: err }));
}
},
...
export default compose(
reduxConnect,
gqlConnectLogin,
gqlConnectRegister,
enhWithState,
enhWithHandlers
)(UserLoginRegister);
This helps me overcome the lack of ability to reflect the results of a graphQl mutation with the Apollo client for a wrapped component. This handles perfectly and without the need for side effects in the component itself.
source
share