File tree 1 file changed +32
-0
lines changed
packages/eslint-plugin-react-hooks/__tests__
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -1755,6 +1755,38 @@ const tests = {
1755
1755
} ,
1756
1756
] ,
1757
1757
} ,
1758
+ {
1759
+ code : normalizeIndent `
1760
+ function MyComponent({ history }) {
1761
+ useEffect(() => {
1762
+ return [
1763
+ history?.foo
1764
+ ];
1765
+ }, [history?.foo]);
1766
+ }
1767
+ ` ,
1768
+ errors : [
1769
+ {
1770
+ message :
1771
+ "React Hook useEffect has a missing dependency: 'history?.foo'. " +
1772
+ 'Either include it or remove the dependency array.' ,
1773
+ suggestions : [
1774
+ {
1775
+ desc : 'Update the dependencies array to be: [history?.foo]' ,
1776
+ output : normalizeIndent `
1777
+ function MyComponent({ history }) {
1778
+ useEffect(() => {
1779
+ return [
1780
+ history?.foo
1781
+ ];
1782
+ }, [history?.foo]);
1783
+ }
1784
+ ` ,
1785
+ } ,
1786
+ ] ,
1787
+ } ,
1788
+ ] ,
1789
+ } ,
1758
1790
{
1759
1791
code : normalizeIndent `
1760
1792
function MyComponent() {
You can’t perform that action at this time.
0 commit comments