File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
exercises/03.use-effect/02.problem.dependencies Expand file tree Collapse file tree 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) {
3030// 🐨 add an optional deps argument here
3131function useEffect ( callback : EffectCallback ) {
3232const 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"
3434effects [ id ] = { callback }
3535}
3636
@@ -74,10 +74,11 @@ function render(newPhase: Phase) {
7474for ( const effect of effects ) {
7575if ( ! effect ) continue
7676
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.
8182
8283effect . callback ( )
8384}
You can’t perform that action at this time.
0 commit comments