Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 44c72f0

Browse files
Completed - epicweb-dev#1 extra 1
1 parent 4adaa64 commit 44c72f0

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

‎src/exercise/01.js‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@
33

44
import * as React from 'react'
55

6-
function countReducer(state,newState) {
7-
return newState
6+
function countReducer(count,step) {
7+
return count+step
88
}
99

1010
function Counter({initialCount = 0, step = 1}) {
11-
// 🐨 replace React.useState with React.useReducer.
12-
// 💰 React.useReducer(countReducer, initialCount)
13-
const [count, setCount] = React.useReducer(countReducer, initialCount)
11+
const [count, changeCount] = React.useReducer(countReducer, initialCount)
1412

15-
// 💰 you can write the countReducer function so you don't have to make any
16-
// changes to the next two lines of code! Remember:
17-
// The 1st argument is called "state" - the current value of count
18-
// The 2nd argument is called "newState" - the value passed to setCount
19-
const increment = () => setCount(count + step)
13+
const increment = () => changeCount(step)
2014
return <button onClick={increment}>{count}</button>
2115
}
2216

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /