-
Notifications
You must be signed in to change notification settings - Fork 402
Closed
Description
When I use the PhoneInput number input without any modifications and type something, it gives the following error:
app-index.tsx:25 Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Way to reproduce;
- Copy PhoneIcon number input code
- Install package
pnpm add react-phone-number-input
- Use it somewhere and type something.
Issue may be related to the react-phone-number-input version.
"react-phone-number-input": "^3.4.12"
Issue can be solved by simply using forwardRef for PhoneInput.
const PhoneInput = React.forwardRef<
HTMLInputElement,
React.ComponentProps<'input'>
>(({ className, ...props }, ref) => {
return (
<Input
data-slot="phone-input"
className={cn(
'-ms-px rounded-s-none shadow-none focus-visible:z-10',
className
)}
ref={ref}
{...props}
/>
);
});
Metadata
Metadata
Assignees
Labels
No labels