What is the TypeScript return type of a React stateless component?

前端 未结 5 509
情深已故
情深已故 2021-01-07 16:17

What would the return type be here?

const Foo
  : () => // ???
  = () => (
    
Foobar
)
5条回答
  •  無奈伤痛
    2021-01-07 16:54

    interface ISomeCoolInterface {
       some: 'string';
       cool: 'string';
       props: 'string' 
    }    
    
    const SomeCoolComponent
        : React.FC 
        = ({ some, cool, props }): JSX.Element => {
            return {some, cool, props}      
        }
    

    The important bit here being the return type JSX.Element

提交回复
热议问题