Browse Source

Added missing function bracket in hooks-effect.md (#2207)

main
Hao Dong 6 years ago
committed by Alexey Pyltsyn
parent
commit
efc3958ba3
  1. 1
      content/docs/hooks-effect.md

1
content/docs/hooks-effect.md

@ -131,6 +131,7 @@ function Example() {
useEffect(() => { useEffect(() => {
document.title = `You clicked ${count} times`; document.title = `You clicked ${count} times`;
}); });
}
``` ```
We declare the `count` state variable, and then we tell React we need to use an effect. We pass a function to the `useEffect` Hook. This function we pass *is* our effect. Inside our effect, we set the document title using the `document.title` browser API. We can read the latest `count` inside the effect because it's in the scope of our function. When React renders our component, it will remember the effect we used, and then run our effect after updating the DOM. This happens for every render, including the first one. We declare the `count` state variable, and then we tell React we need to use an effect. We pass a function to the `useEffect` Hook. This function we pass *is* our effect. Inside our effect, we set the document title using the `document.title` browser API. We can read the latest `count` inside the effect because it's in the scope of our function. When React renders our component, it will remember the effect we used, and then run our effect after updating the DOM. This happens for every render, including the first one.

Loading…
Cancel
Save