Files
react.dev/examples/context/theme-detailed-themed-button.js
Sebastian Markbåge 896214b7d2 Document class contextType as the primary consuming mechanism (#1283)
* Document class contextType as the primary consuming mechanism

* Update context.md
2018-10-23 16:48:02 -07:00

19 lines
381 B
JavaScript

import {ThemeContext} from './theme-context';
class ThemedButton extends React.Component {
// highlight-range{3,12}
render() {
let props = this.props;
let theme = this.context;
return (
<button
{...props}
style={{backgroundColor: theme.background}}
/>
);
}
}
ThemedButton.contextType = ThemeContext;
export default ThemedButton;