Created
July 21, 2018 14:15
-
-
Save Faliszek/226816a7b7829c30fceb898e2a577abb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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