Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d8ac0db

Browse files
jsberlangaJulio Soto
and
Julio Soto
authored
fix: useEffect cleanup function (#122)
Co-authored-by: Julio Soto <julio.soto@schibsted.com>
1 parent 70b23ac commit d8ac0db

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

‎src/final/02.extra-3.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ function useSafeDispatch(dispatch) {
2121
// interact with the dom may depend on the value being set
2222
React.useEffect(() => {
2323
mountedRef.current = true
24-
return () => (mountedRef.current = false)
24+
return () => {
25+
mountedRef.current = false
26+
}
2527
}, [])
2628

2729
return React.useCallback(

‎src/utils.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ function useSafeDispatch(dispatch) {
55

66
React.useLayoutEffect(() => {
77
mounted.current = true
8-
return () => (mounted.current = false)
8+
return () => {
9+
mounted.current = false
10+
}
911
}, [])
1012

1113
return React.useCallback(

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /