Skip to content

Commit 2851956

Browse files
author
Kent C. Dodds
authored
inputs array > dependencies array
I think initially this was referred to as the "inputs array" in the docs, then it was changed to the "dependencies array" everywhere except it looks like a few were missed.
1 parent 24b0f8a commit 2851956

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/docs/hooks-faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ The [`useMemo`](/docs/hooks-reference.html#usememo) Hook lets you cache calculat
740740
const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);
741741
```
742742

743-
This code calls `computeExpensiveValue(a, b)`. But if the inputs `[a, b]` haven't changed since the last value, `useMemo` skips calling it a second time and simply reuses the last value it returned.
743+
This code calls `computeExpensiveValue(a, b)`. But if the dependencies `[a, b]` haven't changed since the last value, `useMemo` skips calling it a second time and simply reuses the last value it returned.
744744

745745
Remember that the function passed to `useMemo` runs during rendering. Don't do anything there that you wouldn't normally do while rendering. For example, side effects belong in `useEffect`, not `useMemo`.
746746

@@ -767,7 +767,7 @@ Note that this approach won't work in a loop because Hook calls [can't](/docs/ho
767767

768768
### How to create expensive objects lazily? {#how-to-create-expensive-objects-lazily}
769769

770-
`useMemo` lets you [memoize an expensive calculation](#how-to-memoize-calculations) if the inputs are the same. However, it only serves as a hint, and doesn't *guarantee* the computation won't re-run. But sometimes you need to be sure an object is only created once.
770+
`useMemo` lets you [memoize an expensive calculation](#how-to-memoize-calculations) if the dependencies are the same. However, it only serves as a hint, and doesn't *guarantee* the computation won't re-run. But sometimes you need to be sure an object is only created once.
771771

772772
**The first common use case is when creating the initial state is expensive:**
773773

0 commit comments

Comments
 (0)