Last active
February 20, 2019 21:56
-
-
Save leonardfactory/c722ad7a389cc7ced9d74f7c9c488525 to your computer and use it in GitHub Desktop.
React Apollo & Hooks
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
// Let's define our context... | |
const ThemeContext = React.createContext(...); | |
// This component is nested in a `ThemeContext.Provider` node.. | |
function MyComponent(props: Props) { | |
// No more HOCs! | |
const theme = useContext(ThemeContext); | |
// It's a kind of magic | |
return ( | |
<h1 style={{ color: theme.color }}>{props.title}</h1> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment