extends-classes | Extend from multiple classes | Reflection library
kandi X-RAY | extends-classes Summary
kandi X-RAY | extends-classes Summary
Extend from multiple classes!
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of extends-classes
extends-classes Key Features
extends-classes Examples and Code Snippets
Community Discussions
Trending Discussions on extends-classes
QUESTION
Component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change to extend React.Component instead
Using the extends-classes library causes a react component to fail rendering with the above error. I'd like to compose a class featuring the React.Component methods and some other methods contained in a different class so I can split my code more concisely.
Example:
...ANSWER
Answered 2019-Sep-19 at 23:08I wouldn't have expected this to work to begin with. Let's examine how this extends-classes
library works.
The classes
function returns a dummy class that within its constructor goes through all classes listed as arguments to the classes
function and copies over all functions and properties to the aforementioned dummy class. It then calls the constructor of all classes.
tl;dr: it mashes everything together so the class you're actually extending from is not an actual instance of React.Component
. Which is most likely why you're getting this error.
Don't fight the language. The language doesn't support multi inheritance. May I suggest you use composition over inheritance instead?
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install extends-classes
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page