File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " eslint-plugin-react-server-components " : minor
3+ ---
4+
5+ allow useMemo hook in RSC
Original file line number Diff line number Diff line change @@ -171,6 +171,13 @@ export function Foo() {
171171}` ,
172172 options : [ { allowedServerHooks : [ "useTranslations" ] } ] ,
173173 } ,
174+ {
175+ code : `import {useMemo} from 'react';
176+ const Button = ({id}) => {
177+ const memoizedId = useMemo(() => id, [id]);
178+ return <div id={memoizedId} />;
179+ }` ,
180+ } ,
174181 ] ,
175182 invalid : [
176183 {
Original file line number Diff line number Diff line change @@ -81,9 +81,8 @@ const create = Components.detect(
8181 function isClientOnlyHook ( name : string ) {
8282 return (
8383 // `useId` is the only hook that's allowed in server components
84- name !== "useId" &&
8584 ! ( options . allowedServerHooks || [ ] ) . includes ( name ) &&
86- / ^ u s e [ A - Z ] / . test ( name )
85+ / ^ u s e (? ! ( I d | M e m o ) $ ) [ A - Z ] / . test ( name )
8786 ) ;
8887 }
8988
You can’t perform that action at this time.
0 commit comments