From 48bb39f10fa87529864c3024392ebd3cc6728582 Mon Sep 17 00:00:00 2001 From: Lisa Smith Date: Wed, 17 Jul 2024 12:10:16 +0000 Subject: [PATCH] fix(eslint): don't read ref.current on render --- .eslintrc.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index f72927e6b8..96e1f3b4fb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -63,6 +63,13 @@ module.exports = { }, ], rules: { + 'no-restricted-syntax': [ + 'warn', + { + 'selector': "JSXAttribute > JSXExpressionContainer > MemberExpression[property.name='current']", + 'message': 'Do not read ref.current on render. Either use useState instead of useRef to store the value, or read ref.current in a useEffect or event handler.' + } + ], quotes: ['error', 'single', { allowTemplateLiterals: true, avoidEscape: true }], 'no-console': ['error', { allow: ['warn'] }], 'no-debugger': 1,