Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

hdiniz
Copy link
Contributor

@hdiniz hdiniz commented Apr 9, 2024

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.

@hdiniz hdiniz self-assigned this Apr 9, 2024
Copy link

vercel bot commented Apr 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
opencollective-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 1:26pm
opencollective-styleguide ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2024 1:26pm

Copy link
Member

@Betree Betree left a 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!

Comment on lines -344 to -345
const budgetItemsParams = [transactions, expenses, filter];
const allItems = React.useMemo(() => getBudgetItems(...budgetItemsParams), budgetItemsParams);
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants