I'm using react-hook-form and I want to set disable to false in one input when I'm typing anything in another input.
my code is (only part of it ofc.):
<label htmlFor="channel">Channel</label>
<input
type="text"
name="channel"
id="channel"
{...register("channel", {
required: {
value: true,
message: "channel is requires",
},
})}
/>
<label htmlFor="twitter">Twitter</label>
<input
type="text"
name="twitter"
id="twitter"
{...register("social.twitter", {
disabled: !dirtyFields.channel,
required: {
value: true,
message: "twitter account is required",
},
})}
/>
it does infinity loop after typing sth in "twitter" input. its becouse of !dirtyFields.channel, when it turn into false, then whole app crashed, but I dont know why, can someone help me with that?
I used watch and touchedFields, but it is this same situation