menu

React Hook Form

📋 Custom React hooks for form validation without the hassle

Channels
Team
Posts
Members
Info

One input depends on another

Hello. Let's say you have two dropdown inputs, Country and City. The City dropdown is populated based on which Country is selected (e.g. Los Angeles and New York would be in the dropdown if USA is selected). How would you get the value of the Country input to the City input so…

thumbsup
1
message-simple
2

MUI Autocomplete default value behaviour

Hi there, I'm using MUI Autocomplete with RFH as per this copy of the MUI example sandbox - https://codesandbox.io/s/react-hook-form-controller-e87nn?file=/src/MuiAutoComplete.js I've tweaked it so that the Autocomplete starting values are supplied in defaultValues instead of in…

thumbsup
0
message-simple
8

Validation with yup not kicking in for mui elements

I am the following this example from docs: https://react-hook-form.com/advanced-usage#CustomHookwithValidationResolver As stated, I created the hook, passed my validation schema to it. Then passed the resolver to useForm hook. I matched the name on validation schema with the…

thumbsup
0
message-simple
3

Manage having two different FieldArray in the form

Hello everyone! I'm having a form as shown in the provided example, where I have two field arrays (Food and Drinks). By clicking the Append food I want to append-only food fields. Same with the drinks fields. Clicking these buttons, new fields are added both in drinks and foods.…

thumbsup
0
message-simple
6

Array of checkboxes?

Hi, I'm trying to have a field that's multiple checkboxes just like this example on MDN titled "Handling multiple checkboxes": https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox#Using_checkbox_inputs I'm a bit at a loss as how to implement that with…

thumbsup
0
message-simple
65

Should the form isValid property be false when a required field is empty?

The form includes 3 text fields and 1 select: 1.) firstName (optional, max length) 2.) lastName (optional, max length) …

thumbsup
0
message-simple
11
Deleted·6d# Help

Form with react native

Hi guys, I am needing to know why do I add if the controller component in my react native project this show me the next error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but go: undefined, this is…

thumbsup
0
message-simple
8

Nested Field Array Not Moving Errors

I've got a multi-tiered nested array setup like this CS https://codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-e616x?file=/src/nestedFieldArray.js. To reproduce the issue I am seeing: • Click 'Append Nested' twice …

thumbsup
0
message-simple
11

Help to useFieldArray in react-hook-form

Hi guys, I'm working on react-hook-form. With form defaultValues = { firstname: 'Kha', lastname: 'Le', skill: {typescript: 'hight', javascript: 'highest'}}. …

thumbsup
0
message-simple
0

How to trigger validation on append/remove

I'm using useFieldArray with some validation on the array itself (users must add a minimum of items or a maximum of items). I want this to be validated/revalidated when the user adds or removes items. Any best practice on how to do this? Is it better to useEffects like…

thumbsup
0
message-simple
11