Skip to content

Button组件loading属性传入null时会抛错 #36282

@kejianfeng

Description

@kejianfeng

Reproduction link

typeof loading === 'object' && loading.delay ? loading.delay || true : !!loading;

Steps to reproduce

<Button loading={null}></Button>

What is expected?

由于某个变量作为loading传入,有时候它可能为null, 希望它跟传入为false一样

What is actually happening?

实际上传入为null时,会直接报错

Environment Info
antd 4.20.2
React 16.12.0
System mac
Browser chrome 102

希望将源码中 typeof loading === 'object' 改为 Object.prototype.toString.call(loading)
这样即便为null也不会报错了

这样会报错的场景组件本身就应该要规避,无论传进什么参数都不至于报错造成页面直接奔溃

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issuehelp wantedThe suggestion or request has been accepted, we need you to help us by sending a pull request.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions