From 9a6aeb30863173b913a313904f9c27ff654a6ef0 Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Thu, 21 Mar 2024 09:59:23 -0600 Subject: [PATCH] add missing instructions --- exercises/06.state-reducer/02.problem.default/app.tsx | 9 +++++++++ exercises/06.state-reducer/02.problem.default/toggle.tsx | 1 + 2 files changed, 10 insertions(+) diff --git a/exercises/06.state-reducer/02.problem.default/app.tsx b/exercises/06.state-reducer/02.problem.default/app.tsx index 5e1c4fc5..deb2a839 100644 --- a/exercises/06.state-reducer/02.problem.default/app.tsx +++ b/exercises/06.state-reducer/02.problem.default/app.tsx @@ -1,5 +1,6 @@ import { useState } from 'react' import { Switch } from '#shared/switch.tsx' +// 🐨 import the toggleReducer import { useToggle } from './toggle.tsx' export function App() { @@ -8,6 +9,14 @@ export function App() { const { on, getTogglerProps, getResetterProps } = useToggle({ reducer(state, action) { + // 🐨 add an if statement for our special logic + // 💰 if the action.type === 'toggle' and clickedTooMuch is true + // then return state + + // 🐨 otherwise call the toggleReducer with the state and action + // and return that. + + // 💣 delete this whole switch statement switch (action.type) { case 'toggle': { if (clickedTooMuch) { diff --git a/exercises/06.state-reducer/02.problem.default/toggle.tsx b/exercises/06.state-reducer/02.problem.default/toggle.tsx index f2c29c8d..88fc5d84 100644 --- a/exercises/06.state-reducer/02.problem.default/toggle.tsx +++ b/exercises/06.state-reducer/02.problem.default/toggle.tsx @@ -11,6 +11,7 @@ type ToggleAction = | { type: 'toggle' } | { type: 'reset'; initialState: ToggleState } +// 🐨 export this function toggleReducer(state: ToggleState, action: ToggleAction) { switch (action.type) { case 'toggle': {