From 05124cd930e4058eadd72cad5364d12db94765fe Mon Sep 17 00:00:00 2001
From: Pascal Fong Kye
Date: Mon, 24 Aug 2020 03:20:53 +0200
Subject: [PATCH] add test on optional chaining in dependency
---
.../__tests__/ESLintRuleExhaustiveDeps-test.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js
index 4de51e9c4043a4..6f153eac9d11fb 100644
--- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js
+++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js
@@ -279,6 +279,18 @@ const tests = {
}
`,
},
+ {
+ code: normalizeIndent`
+ function MyComponent() {
+ const x = true ? { test: true } : undefined;
+ React.useEffect(() => {
+ if (x?.test) {
+ console.log("testing");
+ }
+ }, [x?.test]);
+ }
+ `,
+ },
{
code: normalizeIndent`
function MyComponent(props) {