Expected behaviour: When the form submit button is hit before anything is in the text input, the error message is displayed.
Current behaviour: The error message is only displayed once in input has a value, even after hitting submit. Meaning the user has to click on and type in the textfield before the error message will appear.
I know it was possible to do this in earlier versions of react-hook-form, I think it was the default behaviour actually, surely theres still a way? It seems so simple.
<form className="App" onSubmit={handleSubmit(submitForm)}>
<TextField
label="Attribution"
variant="outlined"
helperText={
Boolean(errors.attribution)
? errors.attribution.message
: "Who is being quoted?"
}
{...register("attribution", {
required: true,
minLength: { value: 3, message: "Please enter a longer name" },
maxLength: { value: 50, message: "Please enter a shorter name" }
})}
error={Boolean(errors.attribution)}
/>
<Button type="submit">Submit</Button>
</form>