Skip to content

Instantly share code, notes, and snippets.

@arist0tl3
Forked from currenthandle/exp.js
Last active February 21, 2019 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arist0tl3/4eae0c3f59ac856343bd0ed028dc49e9 to your computer and use it in GitHub Desktop.
Save arist0tl3/4eae0c3f59ac856343bd0ed028dc49e9 to your computer and use it in GitHub Desktop.
const container = compose(
withStateHandlers({ errors: [] }, {
setErrors: () => errors => ({ errors }),
}),
graphql(LOGIN_MUTATION, {
props: ({ mutate, ownProps }) => ({
login: input =>
mutate({
variables: {
input,
},
})
.then(data => {
console.log('data', data);
if (data.loginResponse) {
ownProps.history.push('/repositories');
}
})
.catch((err) => {
const errors = getErrors(err); // Transform your server-thrown errors
ownProps.setErrors(errors);
}),
}),
}),
withForm({
handleSubmit: (values, { props, setSubmitting, setStatus }) => {
props.login(values);
},
mapPropsToValues: props => ({
username: props.username,
password: props.password,
}),
})
);
type Props = {
handleSubmit: Function,
};
const LoginScene = (props: Props) => (
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment