react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

Update constant name in useImperative example

Open HiteshChoudhary0098 opened this issue 3 years ago • 7 comments

User Imperative example has to same ref name in child and in the parent. Causing confusion while understanding the concept.

function FancyInput(props, ref) { const **inputRef** = useRef(); useImperativeHandle(ref, () => ({ focus: () => { inputRef.current.focus(); } })); return <input ref={**inputRef**} ... />; } FancyInput = forwardRef(FancyInput);

`In this example, a parent component that renders <FancyInput ref={inputRef} /> would be able to call inputRef.current.focus().'

HiteshChoudhary0098 avatar Jul 23 '22 05:07 HiteshChoudhary0098

Size Changes

📦 Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action 🤖

This PR introduced no changes to the javascript bundle 🙌

github-actions[bot] avatar Jul 23 '22 05:07 github-actions[bot]

@sunny minor pr, can you please look into it?

HiteshChoudhary0098 avatar Jul 29 '22 10:07 HiteshChoudhary0098

Wrong @sunny I think :)

sunny avatar Jul 29 '22 11:07 sunny

Wrong @sunny I think :)

updated my comment. can you pls review again?

HiteshChoudhary0098 avatar Aug 17 '22 06:08 HiteshChoudhary0098

@sunny shall I close the pr if the change suggested are wrong?

HiteshChoudhary0098 avatar Aug 18 '22 14:08 HiteshChoudhary0098

What I meant by “Wrong @sunny” is that you mentioned me, but I am not a reactjs.org maintainer.

sunny avatar Aug 18 '22 23:08 sunny

@gaearon can you pls review the pr?

HiteshChoudhary0098 avatar Aug 23 '22 06:08 HiteshChoudhary0098