Skip to content
New issue

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

Incorrect type for geoIpLookup prop #408

Open
usajjad123 opened this issue Nov 14, 2022 · 0 comments
Open

Incorrect type for geoIpLookup prop #408

usajjad123 opened this issue Nov 14, 2022 · 0 comments

Comments

@usajjad123
Copy link

The type of the geoIpLookup is incorrectly defined in IntTelInput.d.ts

Expected Behavior

It should be defined as a function taking callback as an argument:
geoIpLookup?: (callback: (countryCode: string) => void) => void

This can be seen in the documentation and code too:
Screenshot 2022-11-14 at 8 15 27 PM
Screenshot 2022-11-14 at 8 15 39 PM

Current Behavior

It is incorrectly defined as:
geoIpLookup?: (countryCode: string) => void
Screenshot 2022-11-14 at 8 09 35 PM

This causes typescript error when providing geoIpLookup:

Screenshot 2022-11-14 at 8 11 22 PM

Screenshot 2022-11-14 at 8 11 30 PM

Possible Solution

Only needed slight change in the type as suggested above

Steps to Reproduce

  1. Installed react-intl-tel-input lastest version (8.2.0)
  2. Provide the geoIpLookup prop

Code:

<IntlTelInput
        preferredCountries={['ae', 'pk']}
        geoIpLookup={async function (cb) {
          const info = await getIpInfo() // calling the ipinfo.io api
          const countryCode = info && info.country ? info.country : 'pk'
          cb(countryCode)
        }}
        formatOnInit={false}
        format={false}
      />

Environment

  • Version:
    v6.1.0
  • Browser:
    all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant