-
-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix some lint warnings about useMemo #10280
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me so far!
const budgetItemsParams = [transactions, expenses, filter]; | ||
const allItems = React.useMemo(() => getBudgetItems(...budgetItemsParams), budgetItemsParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad that linter doesn't get this, it's a nice syntactic sugar.
This is not an exhaustive fix for this class of lint error, but its a start.
The
useMemo
changes here are relatively safe wrt to side effects, but please take a look if anything stands out.I might do
useCallback
next.I attempted to tackle
useEffect
warnings, but this is a bigger issue, as just adding variables to the dep list to satisfy the linter could affect behavior in subtle ways. In many cases we are falling into an anti-pattern (see https://react.dev/learn/you-might-not-need-an-effect#how-to-remove-unnecessary-effects) and we should adopt another solution.