-
Notifications
You must be signed in to change notification settings - Fork 49.6k
Open
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug
Description
I expect that the the eslint-plugin-react-hooks don't apply to server components.
React version: 19.2
Steps To Reproduce
- Introduce an inpure function in a server side component. E.g. the layout in a nextjs app
- Run eslint with eslint-plugin-react-hooks@7
- Notice error
`Date.now` is an impure function. Calling an impure function can produce unstable results that update unpredictably when the component happens to re-render. (https://react.dev/reference/rules/components-and-hooks-must-be-pure#components-and-hooks-must-be-idempotent).
~/src/inpure-demo/src/app/layout.tsx:25:15
23 | children: React.ReactNode;
24 | }>) {
> 25 | const now = Date.now();
| ^^^^^^^^^^ Cannot call impure function
26 | console.log("Rendering RootLayout at", now);
27 |
28 | return ( react-hooks/purity
Link to code example:
https://github.com/paulvanbrenk/inpure-error-nextjs
The current behavior
Error about the inpure function in a server component
The expected behavior
No error
Pnlvfx
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bug