const onSubmit = data => console.log(data);
<form onSubmit={handleSubmit(onSubmit)}>
<input defaultValue="test001" {...register("var001")} />
{somecondition && (
<>
<input defaultValue="test002" {...register("var002")} />
<input defaultValue="test003" {...register("var003")} />
</>
)}
<input type="submit" />
</form>
I have the following react hook form.
I want console.log(data) to print only of the rendered elements.
So if somecondition is not true
I want to see in console.log(data)
data = {
"var001": "test001"
}
So if somecondition is true
I want to see in console.log(data)
data = {
"var001": "test001"
"var002": "test002",
"var003": "test003",
}
How can i do this
https://codesandbox.io/s/react-hook-form-get-started-forked-55q98
showing the image
