Skip to content

Commit b9ae4d3

Browse files
slemmonmitchellsimoens
authored andcommitted
Update the mobx state example per SME Matias (#54)
1 parent 94ac08b commit b9ae4d3

File tree

1 file changed

+6
-13
lines changed
  • 24-mobx-state/a-application-state-mobx/src

1 file changed

+6
-13
lines changed

24-mobx-state/a-application-state-mobx/src/Form.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import UserStore from './UserStore';
66
@inject(({ store }, { user }) => {
77
return {
88
store,
9-
user: user || (store && store.user)
9+
user
1010
};
1111
})
1212
@observer
@@ -16,15 +16,8 @@ class Form extends Component {
1616
@observable user: {}
1717
}
1818

19-
@action
20-
componentDidMount() {
21-
const { store, user } = this.props;
22-
23-
store.user = user;
24-
}
25-
2619
render() {
27-
const { user } = this.props.store;
20+
const { user } = this.props;
2821
const { renderField, submit } = this;
2922

3023
return (
@@ -67,10 +60,10 @@ class Form extends Component {
6760

6861
@action.bound
6962
handleFieldChange(e) {
70-
const { onChange, store } = this.props;
63+
const { onChange, user } = this.props;
7164
const { name, value } = e.target;
7265

73-
store.user[name] = value;
66+
user[name] = value;
7467

7568
if (onChange) {
7669
onChange({ [name]: value });
@@ -81,7 +74,7 @@ class Form extends Component {
8174
e.preventDefault();
8275

8376
// do submit
84-
};
77+
}
8578
}
8679

87-
export default Form;
80+
export default Form;

0 commit comments

Comments
 (0)