react jsx - Typescript, JSX: render component, passed as argument -
i want write function, renders react component, passed argument function. want handle both component
, statelesscomponent
types. how that:
function rendercomponent(component: react.componentclass<any> | react.statelesscomponent<any>) { return <component />; }
i got compilation error:
error ts2604: jsx element type 'component' not have construct or call signatures.
what doing wrong?
in example rendercomponent
function getting instance of component
, not class/ctor.
should be:
function rendercomponent(componentclass: { new (): react.componentclass<any> | react.statelesscomponent<any> }) { return <componentclass />; }
Comments
Post a Comment