-
Notifications
You must be signed in to change notification settings - Fork 435
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: remove react-hooks linter suppression #8051
base: next
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
No changes to documentation |
Component Testing Report Updated Dec 20, 2024 6:48 PM (UTC) ✅ All Tests Passed -- expand for details
|
⚡️ Editor Performance ReportUpdated Fri, 20 Dec 2024 18:50:11 GMT
Detailed information🏠 Reference resultThe performance result of
🧪 Experiment resultThe performance result of this branch
📚 Glossary
|
9d075f4
to
f5cd7df
Compare
7e2a9ac
to
e3891b3
Compare
a76e797
to
ff14ce1
Compare
// Task is updated on every change, wait until the revision changes to update the activity log. | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [fetchAndParse, task._rev]) | ||
handleFetchAndParse(task._rev) |
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.
Sending the task._rev
here is just to make it a valid useEffect
dependency in the eyes of eslint-plugin-react-hooks/exhaustive-deps
as well as the React Compiler.
// Explicitly don't include `noDocumentsContent` in the deps array, as it's | ||
// causing a visual bug where the "No documents" message is shown for a split second | ||
// when clearing a search query with no results |
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.
I can't reproduce this issue mentioned here, so I think we're good.
In any case, it's not ideal that what initially was just noDocumentsContent
being exempt has eventually led to other deps, t
and paneTitle
, being accidentally omitted.
It demonstrates why it's risky to suppress the linter to begin with 😅
ff14ce1
to
d5e60d5
Compare
d5e60d5
to
7e05a33
Compare
7e05a33
to
d6aa840
Compare
Description
Suppressing the linter on
react-hooks/exhaustive-deps
causes React Compiler to bail, as it can no longer determine if the optimization it plans to do will preserve the original behavior of how often and whenuseEffect
hooks will fire.It's also a bit dangerous to leave in the codebase as what may have started off as omitting a single value from the dependencies array, can over time lead to other values being omitted that would otherwise been caught be the linter.
For example
DocumentListPaneContent
have had its linter suppression for a long long time, and since then we have addedconst {t} = useTranslation(structureLocaleNamespace)
andt
should be a dependency, but it's not.This PR removes all of them, and in the case of
useEffect
theuseEffectEvent
ponyfill is used to preserve the original intent of only having the effect fire when specific dependencies have changed, while no longer suppressing the linter.What to review
Is there enough context?
Testing
Existing tests are sufficient?
Notes for release
Removed
react-hooks/exhaustive-deps
ESLint suppressions, allowing React Compiler to auto-memoize components that were previously skipped over.