Browse Source

Use functional component

main
Alex Krolick 7 years ago
parent
commit
69198013e1
  1. 8
      examples/context/theme-detailed-themed-button.js

8
examples/context/theme-detailed-themed-button.js

@ -1,19 +1,17 @@
import {ThemeContext} from './theme-context';
class ThemedButton extends React.Component {
// highlight-range{3-10}
render() {
function ThemedButton(props) {
// highlight-range{2-9}
return (
<ThemeContext.Consumer>
{theme => (
<button
{...this.props}
{this.props}
style={{backgroundColor: theme.background}}
/>
)}
</ThemeContext.Consumer>
);
}
}
export default ThemedButton;

Loading…
Cancel
Save