Created
July 10, 2020 06:45
-
-
Save vivekascoder/92031f5a4e144ceac2cbbcd7551347e3 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
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import "./styles.css"; | |
const root = document.getElementById("root"); | |
const ThemeContext = React.createContext("light"); | |
function Toolbar(props) { | |
return ( | |
<div> | |
<Button /> | |
</div> | |
); | |
} | |
class Button extends React.Component { | |
static contextType = ThemeContext; | |
render() { | |
return <input type="button" value="CLick Me" theme={this.context} />; | |
} | |
} | |
class App extends React.Component { | |
render() { | |
return ( | |
<ThemeContext.Provider value="dark"> | |
<Toolbar /> | |
</ThemeContext.Provider> | |
); | |
} | |
} | |
ReactDOM.render(<App />, root); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment