Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
franleplant committed Jun 13, 2017
1 parent a4eccae commit 5a2753c
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,12 @@ export default class GettingStarted extends Component {
return event => {
const value = event.target.value;
this.setState(state => {
state.message = ''
state.fields[fieldName] = value;
state.errors = {};
return state;
const fields = {
...state.fields,
[fieldName]: value,
};

return {...state, message: '', error: {}, fields};
});
}
}
Expand Down Expand Up @@ -419,6 +421,9 @@ supposed to work. If you have any problems please report, decorators and mixins
an untamed beast in Typescript land. You can always use the `functionalMixin` but you are going
to need to express the new attributes by hand.

NOTE: important for typescript users, the class based mixins are broken because the type signature is hard to use,
please the other ways of using reform in your components until we fix this.

### Triggering Validation

There are several ways you can trigger validation, let's checkout how:
Expand All @@ -430,15 +435,17 @@ There are several ways you can trigger validation, let's checkout how:
handleChange(e) {
const value = e.target.value;
// this function will validate `value` with `this.validationRules[fieldName]`
// and update `this.state.fields[fieldName]` and `this.state.errors[fieldName]`
// and update `this.state.errors[fieldName]`
// NOTE: this wont update `this.state.fields[fieldName]` with the newest value
this.validateField(fieldName, value);
}

//onBlur
handleBlur() {
// this function will validate `this.state.fields[fieldName]` with `this.validationRules[fieldName]`
// and update the state `this.state.fields[fieldName]` and `this.state.errors[fieldName]`
// and update `this.state.errors[fieldName]`
// Note that we assume that we already have the latest value inside `this.state.fields[fieldName]`
// NOTE: this wont update `this.state.fields[fieldName]` with the newest value
this.validateFieldFromState(fieldName);
}

Expand Down

0 comments on commit 5a2753c

Please sign in to comment.