Skip to content

第4章 Todo示例在控制台中出现警告:TodoItem is changing an uncontrolled input of type checkbox to be controlled #71

Closed
@chocolatl

Description

@chocolatl

新增一个待办事项后将新建的待办事项切换为已完成状态,将会出现警告。原因应该是初始渲染<input>时没有设置value属性。

const checkedProp = completed ? {checked: true} : {};

应该修改为:const checkedProp = completed ? {checked: true} : {checked: false};

另一个示例程序一样:

const checkedProp = completed ? {checked: true} : {};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions