[beta] Added documentation for the useMemo() API reference. (#4928)

* Documentation for useMemo API

* updated

* Update useMemo.md

* Expand useMemo ref

* tweaksg

* oops

Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
This commit is contained in:
Arati Chilad
2022-09-08 17:55:17 -07:00
committed by GitHub
parent b6d597dba3
commit fdc12db196
3 changed files with 1179 additions and 12 deletions

View File

@@ -349,7 +349,9 @@ useInsertionEffect(() => {
Return a memoized callback.
```js
const memoizedCallback = useCallback(callback, [...deps]);
const handleClick = useCallback(() => {
doSomething(a, b);
}, [a, b]);
```
</YouWillLearnCard>
@@ -359,7 +361,9 @@ const memoizedCallback = useCallback(callback, [...deps]);
Return a memoized value.
```js
const memoizedValue = useMemo(() => value, [...deps]);
const value = useMemo(() => {
return calculateValue(a, b);
}, [a, b]);
```
</YouWillLearnCard>

File diff suppressed because it is too large Load Diff

View File

@@ -130,8 +130,7 @@
},
{
"title": "useMemo",
"path": "/apis/react/useMemo",
"wip": true
"path": "/apis/react/useMemo"
},
{
"title": "useReducer",