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