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 (facebook#19145)
  • Loading branch information
yeonjuan authored and trueadm committed Jun 22, 2020
1 parent 3ea9417 commit fe538d1
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 fe538d1

Please sign in to comment.