Closed solo-bog-uptech closed 10 months ago
Hi @solo-bog-uptech, thanks for opening the issue. I have already added support for ref
property and tested it with the following demo component. The new library version will be published after covering all your opened issues (meaning #65).
import Button from "antd/es/button";
import PhoneInput from "antd-phone-input";
import {useForm} from "react-hook-form";
const Demo = () => {
const {register, handleSubmit} = useForm();
const phoneRegister = register("phone", {
validate: ({valid = () => false}: any = {}) => valid(),
});
const onChange = (value: any) => phoneRegister.onChange({target: {value, name: phoneRegister.name}});
return (
<form onSubmit={handleSubmit(console.log)}>
<PhoneInput
enableSearch
{...phoneRegister}
onChange={onChange}
/>
<Button htmlType="submit">Submit</Button>
</form>
)
}
export default Demo;
Closing the issue because of inactivity. The changes will be available in the next release.
Summary
I use react-hook-form lib for handling forms and it needs
ref
prop inPhoneInput
component.