Open axeleroy opened 3 days ago
Had some further discussions internally.
Or at least the documentation does not mention it1.
No Hook can be called in async
Components. You can call it in a sync Component that is used in the Server environment i.e. useId
can be used in shared Components.
I don't understand the logic for preventing any hooks that can run in a Server Component to be called in async
components, especially for a hook as benign as useId
:thinking:
An explanation would be welcome, I might have missed something here.
In #27045 the
eslint-plugin-react-hooks
has been modified to disallow the use of any hooks inasync
components, justified by this sentence:However, some hooks can be called in async components, namely
useId
. Or at least the documentation does not mention it[^1].[^1]: The documentation for React 19 does not mention it as well.
React version: 18.3.1 eslint-plugin-react-hooks: 5.0.0
Steps To Reproduce
useId
The current behavior
ESLint throws an error when an async component uses
useId
.The expected behavior
No ESLint error.