Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve conflicts eef56ffd #367

Merged
merged 33 commits into from
Jul 30, 2019
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
92ad9c2
Update thinking-in-react.md (#2095)
EmmaB Jun 23, 2019
39f30d4
Update thinking-in-react.md (#2098)
EmmaB Jun 24, 2019
cb5a61c
Add missing function call to example (#2102)
ravron Jun 26, 2019
4d1197b
Add description of PropTypes.exact (#1581)
Vlad-UA Jun 29, 2019
1705c25
Improve grammar (#2106)
jsejcksn Jun 30, 2019
6a6b917
Fixed minor code-splitting.md typo (#1292)
mattfwood Jun 30, 2019
aa84270
Fixed broken link to discuss.react.org (#2107)
domclone Jun 30, 2019
7847d23
Update 2019-02-23-is-react-translated-yet.md (#2109)
aatain Jun 30, 2019
6fc8c43
Add Meetup (#2097)
Ayush-Rawal Jun 30, 2019
03260d7
[docs] Updated required node and npm versions to match CRA docs in 'd…
ZachMayer35 Jun 30, 2019
d71c6e3
Remove tooling support info in fragment docs (#2096)
Jun 30, 2019
76588f6
Correct the description of when gDSFP gets called (#2100)
cyan33 Jun 30, 2019
d47597f
Added free Scrimba React Tutorial (#2111)
Jul 1, 2019
c024001
Update Production Optimization docs to use terser (#2112)
Jul 1, 2019
18f662c
Update hooks-faq.md (#2113)
n3dst4 Jul 1, 2019
ed9d731
Update tutorial.md (#2115)
shashank2000 Jul 1, 2019
2dd6924
move past conferences to the bottom of the list (#2118)
azza85 Jul 3, 2019
06a029d
fix(Blog): Post title updated to correct word for yes word in spanish…
akanshgulati Jul 4, 2019
26d9c14
Revert "fix(Blog): Post title updated to correct word for yes word in…
carburo Jul 5, 2019
40e96a4
Add DevExtreme Reactive to the Components list (#2127)
MaximKudriavtsev Jul 6, 2019
b57265b
[Documentation] Fix: Update link to Chrome Accessibility Inspec… (#2134)
nataliemarleny Jul 9, 2019
06dd4cb
React Native added support for hooks in 0.59 (#2121)
gamingumar Jul 9, 2019
e1abbde
Add Kiel to the list of React Meetups (#2136)
dbanck Jul 9, 2019
4af9f2d
Reduce confusion about adding additional fields to .this (#2142)
mikkovedru Jul 11, 2019
b84fb3d
Added option for more cdns. (#2144)
praisedpk Jul 13, 2019
dc650ec
Update docs about an existence of .elementType (#2145)
lonyele Jul 13, 2019
a091165
Revert "Added option for more cdns. (#2144)" (#2146)
alexkrolick Jul 14, 2019
989460f
Add React Conf to list of community conferences (#2158)
jergason Jul 20, 2019
5dca78b
docs(hooks): fix typo (#2161)
neighborhood999 Jul 22, 2019
1d8e542
update the status of Arabic translation .. (#2157)
3imed-jaberi Jul 22, 2019
d00058b
Fixing typo in contributing section of the docs (#2166)
richardtaylordawson Jul 24, 2019
eef56ff
Add a relevant FAQ link in "Thinking In React" (#2170)
colinmorris Jul 25, 2019
7a07441
resolve conflicts eef56ffd
gcor Jul 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs(hooks): fix typo (#2161)
neighborhood999 authored and alexkrolick committed Jul 22, 2019
commit 5dca78b7e3b078df79615cfa6e8cf8464f8b397a
6 changes: 3 additions & 3 deletions content/docs/hooks-faq.md
Original file line number Diff line number Diff line change
@@ -567,7 +567,7 @@ Depending on your use case, there are a few more options described below.

Let's see why this matters.

If you specify a [list of dependencies](/docs/hooks-reference.html#conditionally-firing-an-effect) as the last argument to `useEffect`, `useMemo`, `useCallback`, or `useImperativeHandle`, it must include all values used inside that participate in the React data flow. That includes props, state, and anything derived from them.
If you specify a [list of dependencies](/docs/hooks-reference.html#conditionally-firing-an-effect) as the last argument to `useEffect`, `useMemo`, `useCallback`, or `useImperativeHandle`, it must include all values used inside that participate in the React data flow. That includes props, state, and anything derived from them.

It is **only** safe to omit a function from the dependency list if nothing in it (or the functions called by it) references props, state, or values derived from them. This example has a bug:

@@ -618,7 +618,7 @@ This also allows you to handle out-of-order responses with a local variable insi
const json = await response.json();
if (!ignore) setProduct(json);
}

fetchProduct();
return () => { ignore = true };
}, [productId]);
@@ -677,7 +677,7 @@ function Counter() {

The empty set of dependencies, `[]`, means that the effect will only run once when the component mounts, and not on every re-render. The problem is that inside the `setInterval` callback, the value of `count` does not change, because we've created a closure with the value of `count` set to `0` as it was when the effect callback ran. Every second, this callback then calls `setCount(0 + 1)`, so the count never goes above 1.

Specifying `[count]` as a list of dependencies would fix the bug, but would cause the interval to be reset on every change. Effectively, each `setInterval` would get one chance to execute before being cleared (similar to a `setTimout`.) That may not be desirable. To fix this, we can use the [functional update form of `setState`](/docs/hooks-reference.html#functional-updates). It lets us specify *how* the state needs to change without referencing the *current* state:
Specifying `[count]` as a list of dependencies would fix the bug, but would cause the interval to be reset on every change. Effectively, each `setInterval` would get one chance to execute before being cleared (similar to a `setTimeout`.) That may not be desirable. To fix this, we can use the [functional update form of `setState`](/docs/hooks-reference.html#functional-updates). It lets us specify *how* the state needs to change without referencing the *current* state:

```js{6,9}
function Counter() {