Swap order of increment and decrement in Counter examples (#2382)

I think UI-wise, decrement comes first.
This commit is contained in:
Cheng Lou
2019-10-01 23:27:06 -07:00
committed by Alex Krolick
parent 87685fd27f
commit 453a3bd4f2

View File

@@ -60,8 +60,8 @@ function Counter({initialCount}) {
<>
Count: {count}
<button onClick={() => setCount(initialCount)}>Reset</button>
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button>
<button onClick={() => setCount(prevCount => prevCount - 1)}>-</button>
<button onClick={() => setCount(prevCount => prevCount + 1)}>+</button>
</>
);
}
@@ -231,8 +231,8 @@ function Counter() {
return (
<>
Count: {state.count}
<button onClick={() => dispatch({type: 'increment'})}>+</button>
<button onClick={() => dispatch({type: 'decrement'})}>-</button>
<button onClick={() => dispatch({type: 'increment'})}>+</button>
</>
);
}
@@ -290,8 +290,8 @@ function Counter({initialCount}) {
onClick={() => dispatch({type: 'reset', payload: initialCount})}>
Reset
</button>
<button onClick={() => dispatch({type: 'increment'})}>+</button>
<button onClick={() => dispatch({type: 'decrement'})}>-</button>
<button onClick={() => dispatch({type: 'increment'})}>+</button>
</>
);
}