-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
remove warning for use(Layout)Effect #2358
Conversation
Size Change: -405 B (1%) Total Size: 38.1 kB
ℹ️ View Unchanged
|
Thanks for your quick reaction and the PR. Just re-posting my PR comment here: There are valid use cases where useEffect and useLayoutEffect must be used without a dependency array. As these warnings are not configurable, they are a massive deterioration of the developer experience as it makes the console really messy. In my option there shouldn't be (non-configurable) warnings while using the API as designed. eg. my console gets flooded with 100s of warnings like:
Currently using useImperativeHandle can also trigger a misleading useLayoutEffect warning, as it accepts an empty deps array as well and uses useLayoutEffect in its implementation Examples:
These cases are better covered by the react hooks eslint plugin: |
@xiel thanks for the detailed explanation and my apologies for not reporting back on Slack, I completely forgot to check back. |
Due to a conversation on Slack, which rightfully pointed out that libraries often use this for animations, ... I wanted to put this PR up for discussion. We should refer to
eslint-plugin-hooks
instead of implementing this ourselves. eslint will ensure we only evaluate user codeAnother good argument for removing it: https://github.com/preactjs/preact/blob/master/hooks/src/index.js#L184