From 39ada30616b4342bd8591c934047417a072b58aa Mon Sep 17 00:00:00 2001 From: Justin Jamison Date: Mon, 15 Jul 2024 16:17:39 -0600 Subject: [PATCH 1/4] Update index.tsx Updated some of the instructions to be more clear about intended code outputs. --- exercises/03.use-effect/01.problem.callback/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/exercises/03.use-effect/01.problem.callback/index.tsx b/exercises/03.use-effect/01.problem.callback/index.tsx index a84f4e2..e28759b 100644 --- a/exercises/03.use-effect/01.problem.callback/index.tsx +++ b/exercises/03.use-effect/01.problem.callback/index.tsx @@ -13,6 +13,7 @@ let hookIndex = 0 const states: Array<[any, (newState: any) => void]> = [] type EffectCallback = () => void // 🐨 make a variable called "effects" that's an array of objects with a callback property +// of the "EffectCallback" type we've defined on line 14 above function useState(initialState: State) { const id = hookIndex++ @@ -28,8 +29,8 @@ function useState(initialState: State) { return states[id] as [State, (newState: State) => void] } -// 🐨 create a useEffect function here that accepts a callback, -// gets the id from hookIndex++, and adds it to effects +// 🐨 create a useEffect function here that accepts an "EffectCallback" callback, +// and adds the callback to the effects array at the index "hookIndex++" function Counter() { const [count, setCount] = useState(0) @@ -66,7 +67,8 @@ function render(newPhase: Phase) { // 🐨 wrap this in flushSync appRoot.render() - // 🐨 add a for of loop for all the effects and call their callbacks. + // 🐨 add a for of loop for all the effects and call their callbacks, + // making sure to skip handling of undefined effects } render(INITIALIZATION) From 4a25196140e8639883190c333090cfe1b7d8101b Mon Sep 17 00:00:00 2001 From: Justin Jamison Date: Mon, 15 Jul 2024 16:20:36 -0600 Subject: [PATCH 2/4] Update index.tsx More minor fixes to instructions. --- exercises/03.use-effect/01.problem.callback/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/03.use-effect/01.problem.callback/index.tsx b/exercises/03.use-effect/01.problem.callback/index.tsx index e28759b..c1e6179 100644 --- a/exercises/03.use-effect/01.problem.callback/index.tsx +++ b/exercises/03.use-effect/01.problem.callback/index.tsx @@ -68,7 +68,7 @@ function render(newPhase: Phase) { appRoot.render() // 🐨 add a for of loop for all the effects and call their callbacks, - // making sure to skip handling of undefined effects + // making sure to skip over any undefined effects } render(INITIALIZATION) From 4d40b869e8a5b39589b98c651cb52340e4d4ac51 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Mon, 22 Jul 2024 21:04:09 -0600 Subject: [PATCH 3/4] Update exercises/03.use-effect/01.problem.callback/index.tsx --- exercises/03.use-effect/01.problem.callback/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/03.use-effect/01.problem.callback/index.tsx b/exercises/03.use-effect/01.problem.callback/index.tsx index c1e6179..8bf695f 100644 --- a/exercises/03.use-effect/01.problem.callback/index.tsx +++ b/exercises/03.use-effect/01.problem.callback/index.tsx @@ -67,7 +67,7 @@ function render(newPhase: Phase) { // 🐨 wrap this in flushSync appRoot.render() - // 🐨 add a for of loop for all the effects and call their callbacks, + // 🐨 add a for of loop for all the effects and call their callbacks, // making sure to skip over any undefined effects } From 2f5c1355a4ec41dbe4d365f6f7eae85a29f971e9 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Mon, 22 Jul 2024 21:05:11 -0600 Subject: [PATCH 4/4] Update exercises/03.use-effect/01.problem.callback/index.tsx --- exercises/03.use-effect/01.problem.callback/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/03.use-effect/01.problem.callback/index.tsx b/exercises/03.use-effect/01.problem.callback/index.tsx index 8bf695f..b72863e 100644 --- a/exercises/03.use-effect/01.problem.callback/index.tsx +++ b/exercises/03.use-effect/01.problem.callback/index.tsx @@ -13,7 +13,7 @@ let hookIndex = 0 const states: Array<[any, (newState: any) => void]> = [] type EffectCallback = () => void // 🐨 make a variable called "effects" that's an array of objects with a callback property -// of the "EffectCallback" type we've defined on line 14 above +// of the "EffectCallback" type we've defined above function useState(initialState: State) { const id = hookIndex++