We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import PhoneInput from "react-phone-input-2"; import {PhoneInputProps} from "react-phone-input-2"; import React, {createElement, HTMLAttributes, useEffect, useState} from "react"; // @ts-ignore interface MyPhoneInputProps extends PhoneInputProps, HTMLAttributes<HTMLElement> { myOnlyCountries?: string } const MyPhoneInput: React.FC<MyPhoneInputProps> = function MyPhoneInput(props) { const { value, onChange, myOnlyCountries, ...rest } = props; console.log(props) const [phone, setPhone] = useState(''); const [only, setOnly] = useState(['af', 've']); useEffect(() => { if (typeof myOnlyCountries === 'string') setOnly(['cn', 'af']) }, [myOnlyCountries]) const handlePhoneChange = (e) => { setPhone(e) } return <PhoneInput value={value || phone} onChange={onChange || handlePhoneChange} onlyCountries={only} {...rest} /> } MyPhoneInput.displayName = 'PhoneInput'; export default MyPhoneInput;
When I tried to pass a state to onlyCountries ( in useEffect ), it didn't work.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When I tried to pass a state to onlyCountries ( in useEffect ), it didn't work.
The text was updated successfully, but these errors were encountered: