File tree 1 file changed +6
-5
lines changed
exercises/03.use-effect/02.problem.dependencies
1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ function useState<State>(initialState: State) {
30
30
// 🐨 add an optional deps argument here
31
31
function useEffect ( callback : EffectCallback ) {
32
32
const id = hookIndex ++
33
- // 🐨 add deps to this object and prevDeps should be effects[id]?.deps
33
+ // 🐨 add deps and prevDeps to this object - prevDeps should be " effects[id]?.deps"
34
34
effects [ id ] = { callback }
35
35
}
36
36
@@ -74,10 +74,11 @@ function render(newPhase: Phase) {
74
74
for ( const effect of effects ) {
75
75
if ( ! effect ) continue
76
76
77
- // 🐨 create a hasDepsChanged variable to determine whether the effect should be called
78
- // if the effect has no deps, hasDepsChanged should be true
79
- // if the effect does have deps, calculate whether any item in the dep array
80
- // is different from the corresponding item in the prevDeps array
77
+ // 🐨 Create a "hasDepsChanged" variable to determine whether the effect should be called.
78
+ // If the effect has no deps, "hasDepsChanged" should be true.
79
+ // If the effect does have deps, "hasDepsChanged" should calculate whether any item
80
+ // in the "deps" array is different from the corresponding item in the "prevDeps" array,
81
+ // and return true if so, false otherwise.
81
82
82
83
effect . callback ( )
83
84
}
You can’t perform that action at this time.
0 commit comments