Skip to content

Commit 39ada30

Browse files
authored
Update index.tsx
Updated some of the instructions to be more clear about intended code outputs.
1 parent a7d9278 commit 39ada30

File tree

1 file changed

+5
-3
lines changed
  • exercises/03.use-effect/01.problem.callback

1 file changed

+5
-3
lines changed

exercises/03.use-effect/01.problem.callback/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ let hookIndex = 0
1313
const states: Array<[any, (newState: any) => void]> = []
1414
type EffectCallback = () => void
1515
// 🐨 make a variable called "effects" that's an array of objects with a callback property
16+
// of the "EffectCallback" type we've defined on line 14 above
1617

1718
function useState<State>(initialState: State) {
1819
const id = hookIndex++
@@ -28,8 +29,8 @@ function useState<State>(initialState: State) {
2829
return states[id] as [State, (newState: State) => void]
2930
}
3031

31-
// 🐨 create a useEffect function here that accepts a callback,
32-
// gets the id from hookIndex++, and adds it to effects
32+
// 🐨 create a useEffect function here that accepts an "EffectCallback" callback,
33+
// and adds the callback to the effects array at the index "hookIndex++"
3334

3435
function Counter() {
3536
const [count, setCount] = useState(0)
@@ -66,7 +67,8 @@ function render(newPhase: Phase) {
6667
// 🐨 wrap this in flushSync
6768
appRoot.render(<Counter />)
6869

69-
// 🐨 add a for of loop for all the effects and call their callbacks.
70+
// 🐨 add a for of loop for all the effects and call their callbacks,
71+
// making sure to skip handling of undefined effects
7072
}
7173

7274
render(INITIALIZATION)

0 commit comments

Comments
 (0)