From 563b7fb7e2f6c94a35e5ad63865346ba8fc94857 Mon Sep 17 00:00:00 2001 From: literat Date: Sun, 5 Nov 2023 08:54:19 +0100 Subject: [PATCH] Style(web-react): Introduce ESlint rule to avoid using useLayoutEffect refs #DS-1004 --- packages/web-react/.eslintrc.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/web-react/.eslintrc.js b/packages/web-react/.eslintrc.js index a6ff9cf140..9fd0f232f7 100644 --- a/packages/web-react/.eslintrc.js +++ b/packages/web-react/.eslintrc.js @@ -65,5 +65,16 @@ module.exports = { 'import/no-extraneous-dependencies': ['error', { packageDir: ['./', '../../'] }], // disable double quotes quotes: ['warn', 'single'], + // use useIsomorphicLayoutEffect instead of useLayoutEffect + // @see: https://medium.com/@alexandereardon/uselayouteffect-and-ssr-192986cdcf7a + 'no-restricted-imports': [ + 'error', + // Disabling using of useLayoutEffect from react + { + name: 'react', + importNames: ['useLayoutEffect'], + message: '`useLayoutEffect` causes a warning in SSR. Use `useIsomorphicLayoutEffect`', + }, + ], }, };