Created
June 15, 2018 19:21
-
-
Save thehappybug/7caaad41309ceac333ce171a4adff418 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
// This function takes a component... | |
export function withAppContext(Component) { | |
// ...and returns another component... | |
return function ComponentBoundWithAppContext(props) { | |
// ... and renders the wrapped component with the current context! | |
// Notice that we pass through any additional props as well | |
return ( | |
<AppContextConsumer> | |
{appContext => <Component {...props} appContext={appContext} />} | |
</AppContextConsumer> | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment