Skip to content

Commit d48edf0

Browse files
committed
add test case for facebook#18819
1 parent 40380f2 commit d48edf0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js

+32
Original file line numberDiff line numberDiff line change
@@ -1755,6 +1755,38 @@ const tests = {
17551755
},
17561756
],
17571757
},
1758+
{
1759+
code: normalizeIndent`
1760+
function MyComponent({ history }) {
1761+
useEffect(() => {
1762+
return [
1763+
history?.foo
1764+
];
1765+
}, [history?.foo]);
1766+
}
1767+
`,
1768+
errors: [
1769+
{
1770+
message:
1771+
"React Hook useEffect has a missing dependency: 'history?.foo'. " +
1772+
'Either include it or remove the dependency array.',
1773+
suggestions: [
1774+
{
1775+
desc: 'Update the dependencies array to be: [history?.foo]',
1776+
output: normalizeIndent`
1777+
function MyComponent({ history }) {
1778+
useEffect(() => {
1779+
return [
1780+
history?.foo
1781+
];
1782+
}, [history?.foo]);
1783+
}
1784+
`,
1785+
},
1786+
],
1787+
},
1788+
],
1789+
},
17581790
{
17591791
code: normalizeIndent`
17601792
function MyComponent() {

0 commit comments

Comments
 (0)