👀 useWatch
new compute
props
- subscribe to the entire form but only return updated value with certain condition
type FormValue = {
test: string;
}
const watchedValue = useWatch({
control: methods.control,
compute: (data: FormValue) => {
if (data.test?.length) {
return data.test;
}
return '';
},
});
- subscribe to a specific form value state
type FormValue = {
test: string;
}
const watchedValue = useWatch({
control: methods.control,
name: 'test',
compute: (data: string) => {
return data.length ? data : '';
},
});