-
Hi guys!
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 16 replies
-
can you share a codesandbox? <Input
id="email"
name="email"
placeholder=""
type="email"
className="auth-input"
{...register("email")}
/> The above looks correct if bootstrap exposes the expected props, I am not very familiar with bootstrap. If it's not working you can try to wrap it with some external controlled components examples here: https://codesandbox.io/s/react-hook-form-v7-controller-5h1q5 |
Beta Was this translation helpful? Give feedback.
-
The current reactstrap version 9 is using prop "innerRef" for Input component while "react-hook-form" expects prop "ref" to be registered. I would suggest to pass "ref" from "register('email')" into Input component like this:
Working demo: https://codesandbox.io/s/jovial-dirac-17zpy4?file=/src/App.tsx |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm using reactstrap v9, and don't want to use classNames each time on every input. How to use it properly with reactstrapv9 (multiple fields) ??
|
Beta Was this translation helpful? Give feedback.
-
const { Input } = require("reactstrap");
const FormInput = ({ register, name, ...rest }) => {
const { ref, ...registerField } = register(name);
return <Input innerRef={ref} {...registerField} {...rest} />;
};
export default FormInput; To use it: <FormGroup>
<Label>Email</Label>
<FormInput type="email" name="email" register={register} />
<FormFeedback>{errors.email}</FormFeedback>
</FormGroup> Good luck! |
Beta Was this translation helpful? Give feedback.
@niikkiin, @bluebill1049
The current reactstrap version 9 is using prop "innerRef" for Input component while "react-hook-form" expects prop "ref" to be registered.
I would suggest to pass "ref" from "register('email')" into Input component like this:
Working demo: https://codesandbox.io/s/jovial-dirac-17zpy4?file=/src/App.tsx