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

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

What would the return type be here?

const Foo
  : () => // ???
  = () => (
    
Foobar
)
5条回答
  •  粉色の甜心
    2021-01-07 17:07

    The correct return type here is ReactElement

    , but a better option would be to use React.StatelessComponent

    like this

    const Foo
      : React.StatelessComponent<{}>
      = () => (
        
    Foobar
    )

提交回复
热议问题