Skip to content

Commit

Permalink
Re-add a test from facebook#19260
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Jul 7, 2020
1 parent 2142f31 commit 02f10d9
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6628,6 +6628,44 @@ const testsTypescript = {
},
],
},
{
// https://github.com/facebook/react/issues/19243
code: normalizeIndent`
function MyComponent() {
const pizza = {};
useEffect(() => ({
crust: pizza.crust,
toppings: pizza?.toppings,
}), []);
}
`,
errors: [
{
message:
"React Hook useEffect has missing dependencies: 'pizza.crust' and 'pizza.toppings'. " +
'Either include them or remove the dependency array.',
suggestions: [
{
// TODO the description and suggestions should probably also
// preserve the optional chaining.
desc:
'Update the dependencies array to be: [pizza.crust, pizza.toppings]',
output: normalizeIndent`
function MyComponent() {
const pizza = {};
useEffect(() => ({
crust: pizza.crust,
toppings: pizza?.toppings,
}), [pizza.crust, pizza.toppings]);
}
`,
},
],
},
],
},
],
};

Expand Down

0 comments on commit 02f10d9

Please sign in to comment.