Skip to content

Commit

Permalink
fix: wrapped phone input with forwardRef
Browse files Browse the repository at this point in the history
  • Loading branch information
omeralpi committed Feb 17, 2024
1 parent 39a9ad4 commit 16d4228
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
26 changes: 15 additions & 11 deletions components/ui/phone-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ const PhoneInputSimple = ({ className, children, ...props }: PhoneInputSimplePro
);
PhoneInputSimple.displayName = "PhoneInputSimple";

type PhoneInputProps = React.ComponentProps<typeof RPNInput.default>;

const PhoneInput = ({ className, children, ...props }: PhoneInputProps) => (
<RPNInput.default
className={cn("flex", className)}
placeholder={"Enter a phone number"}
flagComponent={FlagComponent}
countrySelectComponent={CountrySelect}
inputComponent={InputComponent}
{...props}
/>
type PhoneInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> &
RPNInput.Props<typeof RPNInput.default>;

const PhoneInput = React.forwardRef<React.ElementRef<typeof RPNInput.default>, PhoneInputProps>(
({ className, ...props }, ref) => (
<RPNInput.default
ref={ref}
className={cn("flex", className)}
placeholder={"Enter a phone number"}
flagComponent={FlagComponent}
countrySelectComponent={CountrySelect}
inputComponent={InputComponent}
{...props}
/>
),
);

PhoneInput.displayName = "PhoneInput";
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"build": "contentlayer build && next build",
"start": "next start",
"lint": "biome check . && biome format .",
"lint-fix": "biome check . --apply && biome format . --write"
"lint-fix": "biome check . --apply && biome format . --write",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@hookform/resolvers": "^3.3.3",
Expand Down

0 comments on commit 16d4228

Please sign in to comment.