TypeScript and React - children type?

前端 未结 14 1289
借酒劲吻你
借酒劲吻你 2020-12-12 18:56

I have a very simple functional component as follows:

import * as React from \'react\';

export interface AuxProps  { 
    children: React.ReactNode
 }


con         


        
14条回答
  •  萌比男神i
    2020-12-12 19:08

    This is what worked for me:

    interface Props {
      children: JSX.Element[] | JSX.Element
    }
    

    Edit I would recommend using children: React.ReactNode instead now.

提交回复
热议问题