Answer the question
In order to leave comments, you need to log in
React + TypeScript: how to pass a parameter to a component's render()?
The component uses a decorator that needs to be passed to render:
class Preloader extends PureComponent<IPreloader, undefined> {
//...
render(cn: ClassDecorator) {
//...
}
}
export interface IPreloader {
size?: string;
active?: boolean;
color?: string;
render: (cn: ClassDecorator) => any;
}
TS2415: Class 'Preloader' incorrectly extends base class 'PureComponent'.
Types of property 'render' are incompatible.
Type '(cn: ClassDecorator) => Element' is not assignable to type '() => ReactNode'.
Answer the question
In order to leave comments, you need to log in
I think this article should help https://medium.com/@goncalvesjoao/react-es7-decora...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question