Skip to content

Commit

Permalink
fix(eslint-plugin-react-hooks): Added test cases for nullish coalesci…
Browse files Browse the repository at this point in the history
…ng and optional chaining of dependencies, relates to #18985
  • Loading branch information
yanneves committed May 26, 2020
1 parent 67e130f commit 93ccd5a
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,44 @@ const tests = {
}
`,
},
// Nullish coalescing and optional chaining
{
code: normalizeIndent`
function MyComponent(props) {
useEffect(() => {
console.log(props.foo?.bar?.baz ?? null);
}, [props.foo]);
}
`,
},
{
code: normalizeIndent`
function MyComponent(props) {
useEffect(() => {
console.log(props.foo?.bar);
}, [props.foo?.bar]);
}
`,
},
{
code: normalizeIndent`
function MyComponent(props) {
useEffect(() => {
console.log(props.foo);
console.log(props.foo?.bar);
}, [props.foo]);
}
`,
},
{
code: normalizeIndent`
function MyComponent(props) {
useEffect(() => {
console.log(props.foo?.toString());
}, [props.foo]);
}
`,
},
{
code: normalizeIndent`
function MyComponent() {
Expand Down

0 comments on commit 93ccd5a

Please sign in to comment.