Skip to content

Commit 924e76d

Browse files
authored
Merge pull request reactjs#1544 from threepointone/master
rename useImperativeMethods -> useImperativeHandle
2 parents df240a4 + 06b08a2 commit 924e76d

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
- [`useDebugValue`](#usedebugvalue)
2727

@@ -322,18 +322,18 @@ function TextInputWithFocusButton() {
322322

323323
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.
324324

325-
### `useImperativeMethods`
325+
### `useImperativeHandle`
326326

327327
```js
328-
useImperativeMethods(ref, createInstance, [inputs])
328+
useImperativeHandle(ref, createHandle, [inputs])
329329
```
330330

331-
`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`:
331+
`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`:
332332

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

0 commit comments

Comments
 (0)