fix(eslint-plugin): ExhaustiveDeps: Auto fixing should add a dependency array to `useMemo` and `useCallback`
Summary
useMemo and useCallback accept two required parameters. Currently, when including unstable reference in Effect/Memo/Callback dependency array, the eslint plugin will suggest to wrap the unstable reference with useCallback/useMemo
The {reference} function makes the dependencies of useCallback Hook (at line 70) change on every render. To fix this, wrap the definition of 'checkItem' in its own useCallback() Hook.eslintreact-hooks/exhaustive-deps
When accpting the suggestion, It will wrap it with a useMemo/useCallback without a dependency array
const func = useCallback(() => {})
At this point, TypeScript will complain since the second argument of useMemo and useCallback is required.
This PR adds an empty array to the auto-fixing to be like
const func = useCallback(() => {}, [])
Now, the TS error will be fixed. If the function depends on references, the plugin will suggest to add the missing dependencies.
The size diff is too large to display in a single comment. The GitHub action for this pull request contains an artifact called 'sizebot-message.md' with the full message.
Generated by :no_entry_sign: dangerJS against ce5bf45ccde4fa6a76d24cba3ec7b2d9e1a0045d
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| react-compiler-playground | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 27, 2024 10:53am |
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!