1

I want to validate inputs using react-hook-form. but I couldn't send validations rules in register .how to resolve this

https://codesandbox.io/s/react-hook-form-smart-form-component-vpsc0

1 Answer 1

1

I think this question is already resolved at Github issue:

https://codesandbox.io/s/react-hook-form-smart-form-component-17k06

you can pass rules(validation) down as props

<Input name="firstName" rules={{ required: true }} />

export function Input({ register, name, rules, ...rest }) {
  return <input name={name} ref={register(rules)} {...rest} />;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.