sbycrosz / react-native-credit-card-input

Easy, cross-platform credit-card input for your React Native Project! Start accepting payment 💰 in your app today!
MIT License
1.46k stars 699 forks source link

setValues: this.refs object is empty #96

Closed GarimaMathur07 closed 2 months ago

GarimaMathur07 commented 6 years ago

@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.

brasiltrocador commented 6 years ago
                 <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" }); }

GauravRana commented 2 years ago

const refContainer = useRef(null);

<CreditCardInput ref = {refContainer} />

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