Skip to content

Commit 3852a29

Browse files
committed
main 🧊 add memo article
1 parent 16d8a7c commit 3852a29

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

‎packages/docs/app/memoization.md‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,18 @@ Memoization is a tool that should be in the hands of the application developer,
2424
import { useCounter } from '@siberiacancode/reactuse';
2525
import { useCallback, useMemo } from 'react';
2626

27-
function ExpensiveComponent() {
27+
export const Component = () => {
2828
const counter = useCounter(0);
2929

30-
const expensiveValue = useMemo(() => {
31-
return performHeavyCalculation(counter.value);
32-
}, [counter.value]);
30+
const expensiveValue = useMemo(() => performHeavyCalculation(counter.value), [counter.value]);
3331

3432
const handleIncrement = useCallback(() => {
3533
performHeavyOperation();
3634
counter.inc();
3735
}, [counter.inc]);
3836

3937
// ...
40-
}
38+
};
4139
```
4240

4341
## React compiler

0 commit comments

Comments
 (0)