bietkul / react-reactive-form

Angular like reactive forms in React.
MIT License
309 stars 32 forks source link

re render FieldControl triger by state in react component #18

Closed zokypesch closed 6 years ago

zokypesch commented 6 years ago

hii i have problem with fieldControll...

how to render fieldcontrol trigger by state in my own state, example:

this.state = { loginForm : FormBuilder.group({ username: ["", Validators.required], nationality: ["", Validators.required], }), nationalityData: [] // <-- here }

componentDidMount() { ProductApi.product(this.props.token).then(function(product){ let data = product.data.data let dataCbx = []

    data.forEach(value => dataCbx.push({value: value.prod_id, label: value.prod_name}));
    me.setState({nationalityData: dataCbx})

  });

}

}

render(){ console.log(this.state.nationalityData); <---- data is comming not empty array return( <FieldGroup ........> render .... <FieldControl name="nationality" render={(obj) => this.ComboBox(obj)} meta={{data: this.state.nationalityData}} /> ) }

when axios was get data from my backend, it will be set a nationalityData but after set this, the combobox still have no data to show it. i make sure

bietkul commented 6 years ago

Possible duplicate of https://github.com/bietkul/react-reactive-form/issues/10