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
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
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} />;
}