This is my code: https://github.com/Michael-Liendo/url-shortener/blob/main/src/pages/index.js
you can view the problem in: https://shortener.michaelliendo.com/
This is my code: https://github.com/Michael-Liendo/url-shortener/blob/main/src/pages/index.js
you can view the problem in: https://shortener.michaelliendo.com/
You have defined the NewUrlForm component inside the Home component. That is causing the focus issue.
NewUrlForm as a separate component to the Home component level.function NewUrlForm({ onSubmit, originalUrl, inputHandler }) {
return (
<>
<form onSubmit={onSubmit}>
<label
className="block mb-5 text-lg font-medium text-gray-900 dark:text-gray-600"
htmlFor="original-url"
>
URL
</label>
<input
value={originalUrl}
onChange={inputHandler}
className="block w-full px-3 py-1.5 text-base font-normal text-gray-700 bg-white bg-clip-padding border border-solid border-gray-300 rounded transition ease-in-out m-0 focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none
"
id="original-url"
type="text"
placeholder="https://example.com"
required
/>
<button
type="submit"
className="trasition duration-200 text-white bg-blue-700 hover:bg-blue-800 font-medium rounded-lg text-sm px-5 py-2.5 mr-2 mt-6 mb-2 w-full"
>
Create
</button>
</form>
</>
);
}
NewUrlForm component.<NewUrlForm
onSubmit={onSubmit}
originalUrl={originalUrl}
inputHandler={inputHandler}
/>