danielweinmann / react-native-stateless-form

Stateless form components for React Native
MIT License
105 stars 14 forks source link

componentWillReceiveProps(nextProps) needed if extending InlineTextInput class #16

Closed colinwong closed 12 months ago

colinwong commented 6 years ago

The example code provided under 'Create your own component to keep it DRY' isn't working. I had to add the following:

componentWillReceiveProps(nextProps) {
  this.setState({
    value: nextProps.value,
    valid: nextProps.valid,
  });
}

render() {
  return (
      <FormInput
        value={this.state.value}
        valid={this.state.valid}
        {...this.restOfProps}
      />
  );
}

Prop changes was not rippling to the underlying component. Am I doing something wrong? Thanks.