Skip to content

Eui with react-hook-form v7 #4780

Closed Answered by selbina
EvaGarzonBeltran asked this question in Q&A
Discussion options

You must be logged in to vote

Something like the following should work, in case anybody still needs a solution for this.
Note: I haven't tested this precise code -- it was modified from one of react-hook-form's official examples, but I have successfully used this general solution in my own code.

import React from "react";
import { useForm, Controller } from "react-hook-form";

import {
  EuiForm,
  EuiFormRow,
  EuiTextField,
} from '@elastic/eui'

export default function App() {
  const { control, handleSubmit, watch, formState: { errors } } = useForm();
  const onSubmit = data => console.log(data);

  console.log(watch("example")); // watch input value by passing the name of it

  return (
    <EuiForm
      component=

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@EvaGarzonBeltran
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by cee-chen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #4778 on May 05, 2021 00:40.