Skip to content

Commit 806bd38

Browse files
committed
updates src/components/patterns/StateReducer/exercise_2/Field.jsx
1 parent 0ed150d commit 806bd38

File tree

1 file changed

+8
-6
lines changed
  • src/components/patterns/StateReducer/exercise_2

1 file changed

+8
-6
lines changed

src/components/patterns/StateReducer/exercise_2/Field.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,21 @@ export class Field extends React.Component {
1414

1515
onChange = e => {
1616
const { stateReducer } = this.props;
17-
const { state } = this.state;
17+
const { value } = e.target;
1818

19-
this.setState(
20-
stateReducer(state, { type: ON_FIELD_CHANGE, value: e.target.value })
19+
this.setState(state =>
20+
stateReducer(state, { type: ON_FIELD_CHANGE, value })
2121
);
2222
};
2323

2424
onReset = e => {
2525
const { stateReducer } = this.props;
26-
const { state } = this.state;
2726

28-
this.setState(
29-
stateReducer(state, { type: ON_FIELD_RESET, value: this.initialState })
27+
this.setState(state =>
28+
stateReducer(state, {
29+
type: ON_FIELD_RESET,
30+
value: this.initialState.value
31+
})
3032
);
3133
};
3234

0 commit comments

Comments
 (0)