Last active
August 29, 2018 08:06
-
-
Save haldarmahesh/041386b131d2f4b6a3c3d6f1baf3b2e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, { Component } from 'react'; | |
import Header from './Header.component'; | |
import Body from './Body.component'; | |
import ThemeContext from './context/ThemeContext'; | |
import {themeConfig} from './context/ThemeContext'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.state = { | |
theme: 'light' | |
} | |
this.toggleTheme = this.toggleTheme.bind(this); | |
} | |
toggleTheme(newTheme) { | |
this.setState({ | |
theme: newTheme | |
}); | |
} | |
render() { | |
return ( | |
<ThemeContext.Provider value={themeConfig[this.state.theme]}}> | |
<Header toggleTheme={this.toggleTheme}/> | |
<Body/> | |
</ThemeContext.Provider> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment