Browse Source

Change usePrevious example in hooks-faq.md (#2387)

In the example, `count` is initialized to 0 and then multiplied by 100... which is 0.

Changing this to addition so the previous value will differ from the current value.
main
Wes Lord 5 years ago
committed by Alex Krolick
parent
commit
060d129aa0
  1. 2
      content/docs/hooks-faq.md

2
content/docs/hooks-faq.md

@ -373,7 +373,7 @@ Note how this would work for props, state, or any other calculated value.
function Counter() {
const [count, setCount] = useState(0);
const calculation = count * 100;
const calculation = count + 100;
const prevCalculation = usePrevious(calculation);
// ...
```

Loading…
Cancel
Save