What does the error “JSX element type '…' does not have any construct or call signatures” mean?

后端 未结 13 2262
余生分开走
余生分开走 2020-11-28 02:05

I wrote some code:

function renderGreeting(Elem: React.Component) {
    return Hello, !;
}
         


        
13条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 02:37

    I solved it by making use of Type Assertions before exporting the component. TypeScript wasn't able to identify after composing it using redux 'compose' therefore I divided props types into IParentProps and IProps and use IParentProps while doing Type Assertions

    import { compose } from 'react-redux'
    import HOC1 from 'HOCs/HOC1'
    import HOC2 from 'HOCs/HOC2'
    
    type IParentProps = {}
    type IProps = {}
    
    const Component: React.FC = React.memo((props) => {
    
          return 
    
    })
    
    return compose(HOC1,HOC2)(Component) as React.FunctionComponent
    

提交回复
热议问题