Created
January 25, 2019 15:11
-
-
Save bvodola/a6ba9c7ccc8bcda172e33fac16c8f23f 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
// App.js | |
const App = () => | |
<Context.Provider value={this.state.context}> | |
<AppBar onPressLogoutButton={this.logout} /> | |
<View style={{paddingTop: 64}}> | |
<Router> | |
<Route exact path="/" exact component={Home} /> | |
</Router> | |
</View> | |
</Context.Provider> | |
// Context.js | |
import React from 'react'; | |
const Context = React.createContext(); | |
const withContext = (Component) => { | |
return (props) => | |
<Context.Consumer> | |
{context => <Component context={context} {...props} />} | |
</Context.Consumer> | |
} | |
export default Context; | |
export {withContext}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment