我有一个分组产品product-1,它有许多链接产品:
-product-1(分组产品)
我想使用 product-2 的 ID 获取 product-1 的 ID
I want to get the value of a field inside a react-hook-form component and print it outside the form. The value should be updated onChange. is there a way to use the useWatch outside the form component?
import React from "react";
import ReactDOM from "react-dom";
import { useForm, useWatch } from "react-hook-form";
import "./styles.css";
function Form() {
const { register, control, handleSubmit } = useForm();
return (
<>
<form onSubmit={handleSubmit((data) => console.log("data", data))}>
<label>Name:</label>
<input ref={register} name="name" />
<p>{useWatch({ control, …Run Code Online (Sandbox Code Playgroud)