Full Toolkit for Next-Level Domain Analysis
Set current domain as initial value for SearchForm 🔍
Felix Wotschofskybc69f885589f
diff --git a/components/SearchForm.tsx b/components/SearchForm.tsxindex 72fafa2..4da5d2b 100644--- a/components/SearchForm.tsx+++ b/components/SearchForm.tsx@@ -10,12 +10,22 @@ enum FormStates {Success,}-const SearchForm = () => {+type SearchFormProps = {+ initialValue?: string;+};++const SearchForm = (props: SearchFormProps) => {const router = useRouter();const [domain, setDomain] = useState('');const [state, setState] = useState<FormStates>(FormStates.Initial);const [error, setError] = useState(false);+ useEffect(() => {+ if (props.initialValue) {+ setDomain(props.initialValue);+ }+ }, [props.initialValue]);+const handleSubmit = (event: FormEvent) => {event.preventDefault();setError(false);diff --git a/pages/lookup/[domain].tsx b/pages/lookup/[domain].tsxindex 80c1fd7..cce7b9c 100644--- a/pages/lookup/[domain].tsx+++ b/pages/lookup/[domain].tsx@@ -66,7 +66,7 @@ const LookupDomain = ({</Head><Container maxW="container.sm" mb={8}>- <SearchForm />+ <SearchForm initialValue={router.query.domain as string} /></Container><Container maxW="container.xl">