@@ -8,26 +8,26 @@ Introduce a new hook to reduce/improve some process.
8
8
9
9
# Basic example
10
10
11
- In this example ` useEffect ` doesn't need a dependency for read updated ` count ` 's value, so
12
- that's mean whenever ` count ` changes we don't need to perform ` useEffect ` effect function.
13
- ` useStateRef ` just is a name, so might we need to change to better name.
11
+ In this example we see ` useEffect ` that doesn't need a dependency to read updated ` count ` 's
12
+ value, so that's mean we don't need to perform ` useEffect ` effect function event ` count ` will
13
+ change. ` useStateRef ` just is a name, so might we need to change to better name.
14
14
15
15
``` js
16
16
const [count , setCount , getCount ] = useStateRef ();
17
17
18
18
useEffect (() => {
19
- const handleVisibiltuy = () => {
19
+ const handleVisibility = () => {
20
20
console .log (getCount ());
21
21
};
22
22
23
- document .addEventListener (' visibilitychange' , handleVisibiltuy );
23
+ document .addEventListener (' visibilitychange' , handleVisibility );
24
24
25
- return () => document .removeEventListener (' visibilitychange' , handleVisibiltuy );
25
+ return () => document .removeEventListener (' visibilitychange' , handleVisibility );
26
26
}, []);
27
27
```
28
28
29
29
Also, in this example ` useCallback ` doesn't need a dependency to know ` count ` 's value, so
30
- ` useCallback ` inside function just perform once.
30
+ ` useCallback ` inside function just perform once. that's awesome
31
31
32
32
``` js
33
33
const [count , setCount , getCount ] = useStateRef ();
@@ -60,7 +60,7 @@ function useStateRef<T>(initialValue: T): [T, (nextState: T) => void, () => T] {
60
60
# Drawbacks
61
61
62
62
This is a new hook, so we don't have any breaking change, also we can implement that by
63
- internal hook .
63
+ internal React hooks .
64
64
65
65
# Alternatives
66
66
0 commit comments