React-Hook-Form watercooler
July 31, 2019 at 1:06amReact-Hook-Form watercooler
July 31, 2019 at 1:06amOctober 24, 2019 at 11:45pm
October 28, 2019 at 2:15am
hey
check out the validate function
at the bottom of the talbe
you can have multiple validation rules attached to your input
October 31, 2019 at 9:36pm
November 7, 2019 at 4:53am
Thanks . The document is not clear about, validate can be an object. I thought it could only be a function.
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
This conversation has been locked