Files
react.dev/examples/context/forwarding-refs-fancy-button.js
Christian Maughan Tegnér b1d705ad60 Use correct component name in context doc example (#740)
* Use correct component name in context doc example

I'm assuming the intention was to reference the `FancyButton` component defined directly above, unless I'm misunderstanding how to read this example.

* Prettier
2018-03-30 15:08:36 +01:00

19 lines
409 B
JavaScript

class FancyButton extends React.Component {
focus() {
// ...
}
// ...
}
// Use context to pass the current "theme" to FancyButton.
// Use forwardRef to pass refs to FancyButton as well.
// highlight-range{1,3}
export default React.forwardRef((props, ref) => (
<ThemeContext.Consumer>
{theme => (
<FancyButton {...props} theme={theme} ref={ref} />
)}
</ThemeContext.Consumer>
));