`isReactComponent()` returns false for components without `render()`
See original GitHub issueI have few components which render()
method encapsulated into mixin.
Like so:
var Mixin = {
render() {
return (
<h1>{ this.prop.header }</h1><div>{ this._renderBody() }</div>
);
}
};
var Comp1 = React.createClass({
mixins: [ Mixin ],
_renderBody() {
return 'comp 1';
}
});
var Comp2 = React.createClass({
mixins: [ Mixin ],
_renderBody() {
return 'comp 2';
}
});
And because of that some rules are ignored (e.g. sort-comp
rule).
So I propose to check when there is no render()
method inside component if the mixins
prop is declared or not.
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
isReactComponent() returns false for components without ...
I have few components which render() method encapsulated into mixin. Like so: var Mixin = { render() { return ( <h1>{ this.prop.header }</h1>< ......
Read more >How to detect a React component vs. a React element?
Notice the other functions, to determine if a react-element, use the isClassComponent() , yet it returns false for a legitimate React class component....
Read more >React.Component
The render() method is the only required method in a class component. ... render() will not be invoked if shouldComponentUpdate() returns false.
Read more >How to write a React component without using classes or hooks
This new object component can have its own state and methods, some of which can be lifecycle methods (render, componentDidMount, etc.) which ...
Read more >ReactJS | Lifecycle of Components - GeeksforGeeks
If returned false then the subsequent steps of rendering will not be carried out. This function can't be used in the case of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It might be useful to check out react-codemod’s ReactUtils to see the methods they use for this kind of thing.
I’m going to close this; in general, component detection needs some work, but there’s been many updates since this was filed.
New issues with concrete and actionable improvements are welcome!