Skip to content

Commit

Permalink
[eslint-plugin-react-hooks]: handling sparse array when no-inline cal…
Browse files Browse the repository at this point in the history
…lback (#19145)
  • Loading branch information
yeonjuan committed Jun 17, 2020
1 parent cc7c1ae commit 090c6ed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,20 @@ const tests = {
}
`,
},
{
code: normalizeIndent`
function MyComponent({myEffect}) {
useEffect(myEffect, [,myEffect]);
}
`,
},
{
code: normalizeIndent`
function MyComponent({myEffect}) {
useEffect(myEffect, [,myEffect,,]);
}
`,
},
{
code: normalizeIndent`
let local = {};
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default {
if (
declaredDependenciesNode.elements &&
declaredDependenciesNode.elements.some(
el => el.type === 'Identifier' && el.name === callback.name,
el => el && el.type === 'Identifier' && el.name === callback.name,
)
) {
// If it's already in the list of deps, we don't care because
Expand Down

0 comments on commit 090c6ed

Please sign in to comment.