Skip to content

Commit

Permalink
Add test for a constant construction used in multiple dependency arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Aug 13, 2020
1 parent 2b7ae4b commit 31f75cd
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7491,6 +7491,33 @@ const tests = {
},
],
},
{
code: normalizeIndent`
function Foo() {
const foo = {};
useLayoutEffect(() => {
console.log(foo);
}, [foo]);
useEffect(() => {
console.log(foo);
}, [foo]);
}
`,
errors: [
{
message:
"The 'foo' object makes the dependencies of useLayoutEffect Hook (at line 6) change on every render. " +
"To fix this, wrap the initialization of 'foo' in its own useMemo() Hook.",
suggestions: undefined,
},
{
message:
"The 'foo' object makes the dependencies of useEffect Hook (at line 9) change on every render. " +
"To fix this, wrap the initialization of 'foo' in its own useMemo() Hook.",
suggestions: undefined,
},
],
},
],
};

Expand Down

0 comments on commit 31f75cd

Please sign in to comment.