diff --git a/change/@griffel-react-b38d1a6d-6d8d-471e-8e44-e3722096edd2.json b/change/@griffel-react-b38d1a6d-6d8d-471e-8e44-e3722096edd2.json new file mode 100644 index 000000000..4292c8947 --- /dev/null +++ b/change/@griffel-react-b38d1a6d-6d8d-471e-8e44-e3722096edd2.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: make RendererProvider compatible with React Compiler", + "packageName": "@griffel/react", + "email": "olfedias@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/packages/react/src/RendererContext.tsx b/packages/react/src/RendererContext.tsx index 6f99c962f..933ee1126 100644 --- a/packages/react/src/RendererContext.tsx +++ b/packages/react/src/RendererContext.tsx @@ -28,18 +28,13 @@ const RendererContext = React.createContext(createDOMRenderer() * @public */ export const RendererProvider: React.FC = ({ children, renderer, targetDocument }) => { - 'use no memo'; - - if (canUseDOM()) { - // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after - // mounting. - // eslint-disable-next-line react-hooks/rules-of-hooks - React.useMemo(() => { + React.useMemo(() => { + if (canUseDOM()) { // "rehydrateCache()" can't be called in effects as it needs to be called before any component will be rendered to // avoid double insertion of classes rehydrateRendererCache(renderer, targetDocument); - }, [renderer, targetDocument]); - } + } + }, [renderer, targetDocument]); return {children}; };