eslint-plugin-react-hook-form
Version:
ESLint plugin for react-hook-form
46 lines (30 loc) • 1.05 kB
Markdown
This ensures the hook has subscribed to the changes of the states when you use React Compiler.
Since using useMemo with `watch` will cause results to be stale when you use React Compiler. This is part of a pattern, where non-hook APIs should always be memoizable.
Examples of **incorrect** code for this rule:
```jsx
// ❌ should not use watch.
const { watch } = useForm();
```
```jsx
// ❌ should not use watch.
const { watch } = useFormContext();
```
Examples of **correct** code for this rule:
```jsx
// ✅ Use useWatch instead of watch
const { control } = useForm();
const watchedValues = useWatch({ control });
```
```jsx
// ✅ Use useWatch instead of watch
const { control } = useFormContext();
const watchedValues = useWatch({ control });
```
NA
NA
[](https://github.com/react-hook-form/react-hook-form/issues/11910)