Skip to content

Commit

Permalink
add missing instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
kentcdodds committed Mar 21, 2024
1 parent 29df830 commit 9a6aeb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions exercises/06.state-reducer/02.problem.default/app.tsx
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions exercises/06.state-reducer/02.problem.default/toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down

0 comments on commit 9a6aeb3

Please sign in to comment.