Closed zokypesch closed 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
Possible duplicate of https://github.com/bietkul/react-reactive-form/issues/10
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 = []
}
}
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