Skip to content

Instantly share code, notes, and snippets.

@Faliszek
Created July 21, 2018 14:15
Show Gist options
  • Save Faliszek/226816a7b7829c30fceb898e2a577abb to your computer and use it in GitHub Desktop.
Save Faliszek/226816a7b7829c30fceb898e2a577abb to your computer and use it in GitHub Desktop.
export function withAuthContext<Props: Object>(
Component: ComponentType<Props>
): ComponentType<$Diff<Props, State>> {
return function AuthContextConsumerWrapper(props: Props) {
return (
<AuthContextConsumer>{context => <Component {...context} {...props} />}</AuthContextConsumer>
);
};
}
export function withAuth<Props: Object>(
Component: ComponentType<Props>
): ComponentType<$Diff<Props, State>> {
return compose(graphql(LOGIN_MUTATION, { name: "loginUser" }))(withAuthContext(Component));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment