Files
react.dev/examples/context/forwarding-refs-app.js
2018-03-23 09:23:04 -07:00

12 lines
347 B
JavaScript

import FancyButton from './fancy-button';
const ref = React.createRef();
// Our ref will point to the FancyButton component,
// And not the ThemeContext.Consumer that wraps it.
// This means we can call FancyButton methods like ref.current.focus()
// highlight-next-line
<FancyButton ref={ref} onClick={handleClick}>
Click me!
</FancyButton>;