You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
630 B
30 lines
630 B
import {ThemeContext, themes} from './theme-context';
|
|
import ThemedButton from './button';
|
|
|
|
class App extends React.Component {
|
|
state = {
|
|
theme: themes.light,
|
|
};
|
|
|
|
toggleTheme = () => {
|
|
this.setState(state => ({
|
|
theme:
|
|
state.theme === themes.dark
|
|
? themes.light
|
|
: themes.dark,
|
|
}));
|
|
};
|
|
|
|
render() {
|
|
//highlight-range{2,6}
|
|
return (
|
|
<ThemeContext.Provider value={this.state.theme}>
|
|
<ThemedButton onClick={this.toggleTheme}>
|
|
Change Theme
|
|
</ThemedButton>
|
|
</ThemeContext.Provider>
|
|
);
|
|
}
|
|
}
|
|
|
|
ReactDOM.render(<App />, document.root);
|
|
|