Skip to content

Commit 53222c7

Browse files
author
Sunil Pai
committed
rename useImperativeMethods -> useImperativeHandle
1 parent b5fa1df commit 53222c7

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

content/docs/hooks-faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ This might look strange at first, but an update during rendering is exactly what
304304

305305
### Can I make a ref to a function component?
306306

307-
While you shouldn't need this often, you may expose some imperative methods to a parent component with the [`useImperativeMethods`](/docs/hooks-reference.html#useimperativemethods) Hook.
307+
While you shouldn't need this often, you may expose some imperative methods to a parent component with the [`useImperativeHandle`](/docs/hooks-reference.html#useimperativehandle) Hook.
308308

309309
### What does `const [thing, setThing] = useState()` mean?
310310

content/docs/hooks-reference.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ If you're new to Hooks, you might want to check out [the overview](/docs/hooks-o
2121
- [`useCallback`](#usecallback)
2222
- [`useMemo`](#usememo)
2323
- [`useRef`](#useref)
24-
- [`useImperativeMethods`](#useimperativemethods)
24+
- [`useImperativeHandle`](#useimperativehandle)
2525
- [`useLayoutEffect`](#uselayouteffect)
2626

2727
## Basic Hooks
@@ -321,18 +321,18 @@ function TextInputWithFocusButton() {
321321

322322
Note that `useRef()` is useful for more than the `ref` attribute. It's [handy for keeping any mutable value around](/docs/hooks-faq.html#is-there-something-like-instance-variables) similar to how you'd use instance fields in classes.
323323

324-
### `useImperativeMethods`
324+
### `useImperativeHandle`
325325

326326
```js
327-
useImperativeMethods(ref, createInstance, [inputs])
327+
useImperativeHandle(ref, createInstance, [inputs])
328328
```
329329

330-
`useImperativeMethods` customizes the instance value that is exposed to parent components when using `ref`. As always, imperative code using refs should be avoided in most cases. `useImperativeMethods` should be used with `forwardRef`:
330+
`useImperativeHandle` customizes the instance value that is exposed to parent components when using `ref`. As always, imperative code using refs should be avoided in most cases. `useImperativeHandle` should be used with `forwardRef`:
331331

332332
```js
333333
function FancyInput(props, ref) {
334334
const inputRef = useRef();
335-
useImperativeMethods(ref, () => ({
335+
useImperativeHandle(ref, () => ({
336336
focus: () => {
337337
inputRef.current.focus();
338338
}

0 commit comments

Comments
 (0)