Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
behnammodi committed Aug 27, 2021
1 parent 3b6d37e commit e81cdf7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions text/0000-use-state-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ Introduce a new hook to reduce/improve some process.

# Basic example

In this example `useEffect` doesn't need a dependency for read updated `count`'s value, so
that's mean whenever `count` changes we don't need to perform `useEffect` effect function.
`useStateRef` just is a name, so might we need to change to better name.
In this example we see `useEffect` that doesn't need a dependency to read updated `count`'s
value, so that's mean we don't need to perform `useEffect` effect function event `count` will
change. `useStateRef` just is a name, so might we need to change to better name.

```js
const [count, setCount, getCount] = useStateRef();

useEffect(() => {
const handleVisibiltuy = () => {
const handleVisibility = () => {
console.log(getCount());
};

document.addEventListener('visibilitychange', handleVisibiltuy);
document.addEventListener('visibilitychange', handleVisibility);

return () => document.removeEventListener('visibilitychange', handleVisibiltuy);
return () => document.removeEventListener('visibilitychange', handleVisibility);
}, []);
```

Also, in this example `useCallback` doesn't need a dependency to know `count`'s value, so
`useCallback` inside function just perform once.
`useCallback` inside function just perform once. that's awesome

```js
const [count, setCount, getCount] = useStateRef();
Expand Down Expand Up @@ -60,7 +60,7 @@ function useStateRef<T>(initialValue: T): [T, (nextState: T) => void, () => T] {
# Drawbacks

This is a new hook, so we don't have any breaking change, also we can implement that by
internal hook.
internal React hooks.

# Alternatives

Expand Down

0 comments on commit e81cdf7

Please sign in to comment.