Reactjs 如果没有子项,则获取零子项计数

Reactjs 如果没有子项,则获取零子项计数,reactjs,Reactjs,查看下面的用法 <Button btnStyle="primary" icon={Close} /> 但这总是返回1 因此,如果未定义子项,我如何隐藏span?我不明白:和应该有props.children未定义,那么在执行时,您怎么可能有props.children。你能演示一下这个问题吗?看,确实不应该。所以,我想相信儿童作为道具应该是未定义的。因此,条件1应该起作用。对吗? <ButtonSolid onClick={handleClick} btnTy

查看下面的用法

<Button btnStyle="primary" icon={Close} />
但这总是返回1


因此,如果未定义子项,我如何隐藏span?我不明白:
应该有props.children未定义,那么在执行
时,您怎么可能有props.children。你能演示一下这个问题吗?看,确实不应该。所以,我想相信
儿童
作为道具应该是
未定义的
。因此,条件1应该起作用。对吗?
<ButtonSolid
    onClick={handleClick}
    btnType={btnType}
    btnStyle={btnStyle}
    type={htmlType}
    {...rest}
>
    {icon ? getIcon(btnStyle, btnType) : null}
   {children ? (
    <span
        style={{
            marginLeft: "5px"
        }}
    >
        {children}
    </span>
) : null}
</ButtonSolid>
React.Children.count(children)? spanElem : null