committed by
GitHub
9 changed files with 96 additions and 57 deletions
@ -0,0 +1,10 @@ |
|||
class App extends React.Component { |
|||
render() { |
|||
// highlight-range{2}
|
|||
return ( |
|||
<Provider value={{something: 'something'}}> |
|||
<Toolbar /> |
|||
</Provider> |
|||
); |
|||
} |
|||
} |
@ -0,0 +1,17 @@ |
|||
class App extends React.Component { |
|||
constructor(props) { |
|||
// highlight-range{2}
|
|||
this.state = { |
|||
value: {something: 'something'}, |
|||
}; |
|||
} |
|||
|
|||
render() { |
|||
// highlight-range{2}
|
|||
return ( |
|||
<Provider value={this.state.value}> |
|||
<Toolbar /> |
|||
</Provider> |
|||
); |
|||
} |
|||
} |
@ -1,19 +1,17 @@ |
|||
import {ThemeContext} from './theme-context'; |
|||
|
|||
class ThemedButton extends React.Component { |
|||
// highlight-range{3-10}
|
|||
render() { |
|||
return ( |
|||
<ThemeContext.Consumer> |
|||
{theme => ( |
|||
<button |
|||
{...this.props} |
|||
style={{backgroundColor: theme.background}} |
|||
/> |
|||
)} |
|||
</ThemeContext.Consumer> |
|||
); |
|||
} |
|||
function ThemedButton(props) { |
|||
// highlight-range{2-9}
|
|||
return ( |
|||
<ThemeContext.Consumer> |
|||
{theme => ( |
|||
<button |
|||
{...props} |
|||
style={{backgroundColor: theme.background}} |
|||
/> |
|||
)} |
|||
</ThemeContext.Consumer> |
|||
); |
|||
} |
|||
|
|||
export default ThemedButton; |
|||
|
Loading…
Reference in new issue