简体   繁体   中英

Can I trigger onChange function when there is an automated value for input?

I have a Form.Input

<Form.Input
fluid
required
label="First name"
placeholder="Jose"
name="firstName"
value={ _.isNil(selectedProfile) ? firstName : selectedProfile.first_name }
onChange={this.onCustomerFieldUpdate}
/>

as you can see from my code, I am checking if selectedProfile is Null or not, if it is null, it will accept the input, but if not, It will get the value for selectedProfile.first_name . the problem is, I want to trigger onCustomerFieldUpdate even though it gets the value from selectedProfile.first_name but it doesn't because it can be triggered onChange . is there a way that I can call onCustomerFieldUpdate when my value is from selectedProfile.first_name ?

根据检查条件,可以从componentDidMount方法调用this.onCustomerFieldUpdate。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM