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'; |
import {ThemeContext} from './theme-context'; |
||||
|
|
||||
class ThemedButton extends React.Component { |
function ThemedButton(props) { |
||||
// highlight-range{3-10}
|
// highlight-range{2-9}
|
||||
render() { |
return ( |
||||
return ( |
<ThemeContext.Consumer> |
||||
<ThemeContext.Consumer> |
{theme => ( |
||||
{theme => ( |
<button |
||||
<button |
{...props} |
||||
{...this.props} |
style={{backgroundColor: theme.background}} |
||||
style={{backgroundColor: theme.background}} |
/> |
||||
/> |
)} |
||||
)} |
</ThemeContext.Consumer> |
||||
</ThemeContext.Consumer> |
); |
||||
); |
|
||||
} |
|
||||
} |
} |
||||
|
|
||||
export default ThemedButton; |
export default ThemedButton; |
||||
|
Loading…
Reference in new issue