React-Hook-Form watercooler
July 31, 2019 at 1:06amReact-Hook-Form watercooler
July 31, 2019 at 1:06amNovember 7, 2019 at 5:41am
How do I change the style/className of input when an error is displayed?
The method I'm using right now is not very good is there a right way?
nope, it is included in the document in the register part of API section.
November 7, 2019 at 10:00pm
Have you considered using https://www.npmjs.com/package/classnames
thanks, I'll look it
November 29, 2019 at 10:36am
Hey I've problems with ref + bootstrap + typescript I've created a bug https://github.com/react-hook-form/react-hook-form/issues/598
December 4, 2019 at 5:39pm
Hi all, I am considering this library for use in the project were we have several custom components which don't expose refs so idea is to use setValue function when value changes like ReactSelect is used in the example:
From the example:
We track components state manually:
const [values, setReactSelect] = useState({selectedOption: []});
Then change handler is defined and it needs to call two state update functions:
const handleMultiChange = selectedOption => {setValue("reactSelect", selectedOption);setReactSelect({ selectedOption });};
And finally we use component like:
<SelectclassName="reactSelect"name="filters"placeholder="Filters"value={values.selectedOption}options={options}onChange={handleMultiChange}isMulti/>
This seems like a lot of extra work, especially if you have 10 such components on the form.
My question is can we use something like this:
<SelectclassName="reactSelect"name="filters"placeholder="Filters"value={watch("reactSelect")}options={options}onChange={handleMultiChange}isMulti/>
or this:
<SelectclassName="reactSelect"name="filters"placeholder="Filters"value={getValues().reactSelect}options={options}onChange={handleMultiChange}isMulti/>
or is there some other solution?
Thanks,
Milos
December 5, 2019 at 1:03am
Try searching for
react-hook-form-input
December 5, 2019 at 9:10am
Hi , thanks for the reply. I've seen that, I can give it a try although it is an extra dependency.
But what do you think about solutions proposed above (watch and getValues)?
December 6, 2019 at 2:00am
December 10, 2019 at 2:58pm
I'm trying to reset/clear the value of the subform. But the Main form get cleared as well.
Thank you for replying very quick. There are not errors, but I don't want to reset the value of name, only the value of "other"
Please, see me my edited answer.
In my example is not exactly like my code but I had to make it easy and sort, the subform shouldn't be aware of the mainForm, they are independent components
the idea of the subform is to add elements to a list that belongs to the main form
when you add it I want that subform to be cleared
I will try with that reset, but I find it weird the second reset clear the first form
This conversation has been locked