react-native-credit-card-input icon indicating copy to clipboard operation
react-native-credit-card-input copied to clipboard

setValues: this.refs object is empty

Open GarimaMathur07 opened this issue 7 years ago • 2 comments
trafficstars

@sbycrosz Set values into credit card form:

When i use credit card input library in my project and i have to set card values after card scan then this.refs object is empty from this line: this.refs.CCInput.setValues({ number: "4242" });

So, how can i set values after card scanning.

GarimaMathur07 avatar Jan 18 '18 11:01 GarimaMathur07

                 <CreditCardInput
                        ref={(c) => this.CCInput = c} -----> include
                        autoFocus

                        requiresName
                        requiresCVC
                        requiresPostalCode


                        labelStyle={s.label}
                        inputStyle={s.input}
                        validColor={"black"}
                        invalidColor={"red"}
                        cvc={'123'}
                        placeholderColor={"darkgray"}


                        onFocus={this._onFocus}
                        onChange={this._onChange} />

use this _post = () =>{ this.CCInput.setValues({ number: "4242" }); }

brasiltrocador avatar Jan 21 '18 13:01 brasiltrocador

const refContainer = useRef(null);

<CreditCardInput ref = {refContainer} />

let startScan = async() =>{ refContainer.current.setValues({ number: "4242424242" }); }

GauravRana avatar Sep 08 '22 07:09 GauravRana