mirror of
https://github.com/Xevion/rdap.git
synced 2025-12-06 01:16:00 -06:00
Add onChange prop to LookupInput, add default value to 'target' in useForm hook
This commit is contained in:
@@ -10,14 +10,17 @@ type LookupInputProps = {
|
||||
onRegistry?: (type: TargetType) => Promise<any>;
|
||||
// When a user hits submit, this is called.
|
||||
onSubmit?: (props: SubmitProps) => Promise<any>;
|
||||
onChange?: (target: string) => any;
|
||||
};
|
||||
|
||||
const LookupInput: FunctionComponent<LookupInputProps> = ({
|
||||
isLoading,
|
||||
onSubmit,
|
||||
onChange,
|
||||
}: LookupInputProps) => {
|
||||
const { register, handleSubmit } = useForm<SubmitProps>({
|
||||
const { register, handleSubmit, getValues } = useForm<SubmitProps>({
|
||||
defaultValues: {
|
||||
target: "",
|
||||
followReferral: false,
|
||||
requestJSContact: false,
|
||||
},
|
||||
@@ -48,7 +51,12 @@ const LookupInput: FunctionComponent<LookupInputProps> = ({
|
||||
disabled={isLoading}
|
||||
placeholder="A domain, an IP address, a TLD, an RDAP URL..."
|
||||
type="search"
|
||||
{...register("target", { required: true })}
|
||||
{...register("target", {
|
||||
required: true,
|
||||
onChange: () => {
|
||||
if (onChange != undefined) onChange(getValues("target"));
|
||||
},
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user