mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-23 20:23:08 +00:00
Added React.forwardRef to API and docs
This commit is contained in:
15
examples/forwarding-refs/fancy-button-ref.js
Normal file
15
examples/forwarding-refs/fancy-button-ref.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import FancyButton from './FancyButton';
|
||||
|
||||
// highlight-next-line
|
||||
const ref = React.createRef();
|
||||
|
||||
// The FancyButton component we imported is the LogProps HOC.
|
||||
// Even though the rendered output will be the same,
|
||||
// Our ref will point to LogProps instead of the inner FancyButton component!
|
||||
// This means we can't call e.g. ref.current.focus()
|
||||
// highlight-range{4}
|
||||
<FancyButton
|
||||
label="Click Me"
|
||||
handleClick={handleClick}
|
||||
ref={ref}
|
||||
/>;
|
||||
Reference in New Issue
Block a user