jorisre / react-telephone Goto Github PK
View Code? Open in Web Editor NEW☎️ Tiniest react phone input component (auto formating included)
Home Page: https://react-telephone.joris.re/
License: MIT License
☎️ Tiniest react phone input component (auto formating included)
Home Page: https://react-telephone.joris.re/
License: MIT License
I don't know if it is possible but how can we see the value typed or selected country in a form? Especially with formik.
The most common number format used in China is 3/4/4 (XXX XXXX XXXX
). Dash (-
) is never used here.
In Google's libphonenumber the metadata is like this:
Id ; National ; Carrier ; International ; Local ; National Prefix Optional ; Comment
...
mobile_3/4/4 ; "XXX XXXX XXXX" ; "@ XXX XXXX XXXX" ; "XXX XXXX XXXX" ; ; ; "Mobile range"
...
I am trying to get the input to work with the hook form controller component and it throws an error when the defaultCountry value is set.
<Controller
control={control}
name="phoneNumber"
rules={{
required: 'Please add a phone number',
}}
render={({ field, fieldState }) => (
<Phone {...field} defaultCountry="us">
<Phone.Country
className={
'rounded-br-none rounded-bl-none focus:border focus:border-gray-300 focus:ring-transparent'
}
/>
<Phone.Number
className={
'rounded-tr-none rounded-tl-none border-t-0 focus:border focus:border-t-0 focus:border-gray-300 focus:ring-transparent'
}
/>
</Phone>
)}
/>
Here is a sandbox of the issue https://stackblitz.com/edit/github-nhjwbd?file=src/components/samples/ReactHookForm.tsx
Any suggestions or ideas why this may be happening?
Actual result:
Nothing happens.
Browser: Microsoft Edge: 103.0.1264.37 (Official build) (64-bit)
I am receiving the following error message when I am selecting the US as phone number and there is already a number in the input:
Cannot read properties of undefined (reading '3')
See this video here that shows the issue.
It works with other countries. Perhaps it has something to do with the expected format of the input and the German number is too long which was previously in there?
Hi guys,
It seems that there is a compatibility error with older react version (^16.14.0).
ERROR in ./node_modules/react-telephone/dist/react-telephone.modern.js 1:0-56
Module not found: Error: Can't resolve 'react/jsx-runtime' in 'C:\XXXXXX\node_modules\react-telephone\dist'
Did you mean 'jsx-runtime.js'?
BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the ppackage.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.
Bonne journée à vous!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.