james bond james bond - 3 months ago 22
TypeScript Question

Generic Extended React Component Typescript

Im looking to extend the React Component class with my own class.

export class ReactComponent<P,S> extends React.Component<P,S> {
public doStuff() {
alert("Custom React Component");
}
}

export class MyComponent extends ReactComponent<MyProps, any> {
render() {
return <div onLoad={this.doStuff()}></div>;
}
}


This appears to compile but throws the following error on load.


Uncaught TypeError: Super expression must either be null or a function, not undefined


Using React 15.3, I must be missing something.

Answer

Uncaught TypeError: Super expression must either be null or a function, not undefined

Most likely an ordering issue. Make sure that the javascript is loaded in the right order.

More