sort-comp does not detect component declaration starting with return
#1076
Closed
Description
Similar to #174 a component is not detected if the declaration begins with return
(Such as, in our case, where we're wrapping the component inside a HOC). Other react rules appear to be applied correctly to these cases, just not sort-comp
.
Example code (does not show sort-comp
warning):
let makeComp = () => {
return class MyComponent extends React.Component {
componentDidUpdate () { }
componentDidMount () {}
constructor () { super(); }
};
};
Example code (correctly shows sort-comp
warning):
let makeComp = () => {
class MyComponent extends React.Component {
componentDidUpdate () { }
componentDidMount () {}
constructor () { super(); }
};
return MyComponent;
};
As another note: The react lifecycle methods are out-of-order and yet generate no warning. Not sure why they are not, maybe that's another ticket.