Open magicxor opened 2 years ago
Also seeing this issue. The main problem I see is that the only way to do custom rendering based on the validity of the phone number is using isValid
, except value
and isValid
both trigger renders, and this conflicts with any custom rendering you're doing with the component.
The most straight-forward solution (I think) would be for the onChange
even to pass in availableCountries
so that state changes and validation can all happen in the same place.
I think it can be fixed by implementing it in this way
let isValidRef = useRef(false)
useEffect(() => {
setIsValid(isValidRef.current);
}, [isValidRef.current]);
const validatePhone = () => {
const isValid = true // validation logic here
isValidRef.current = isValid;
}
Hi. I got the following warning:
when I set the
isValid
callback.Repro:
package.json
App.tsx
Please tell me if there is some workaround.