redux-form: How to disable submit button if at least one Field is not valid?
Don't abuse state you need just using this.propsfor each setState Component one more time will be render
const {invalid} = this.propsreturn(<button type="submit" className="btn btn-default" disabled={invalid|| submitting || pristine}> Blogeintrag speichern </button>)
More Document:https://redux-form.com/6.0.0-alpha.4/docs/api/props.md/
Redux forms already passes lots of properties into the form. One is invalid
. That's what I am using to determine if any of the field validations failed and then disable submit.
What you should be able to do is just have a variables called Errors
that will be true once your api call comes back with an error
constructor(super) { this.state = { errors: false, } } componentWillReceiveProps(nextProps) { const that = this; if (nextProps.errors) { that.setState({errors: true}) } } <button type="submit" className="btn btn-default" disabled={this.state.errors || submitting || pristine}> Blogeintrag speichern </button>