【问题标题】:react react-jsonschema-form update state反应 react-jsonschema-form 更新状态
【发布时间】:2018-05-09 21:27:30
【问题描述】:

我有这个使用react-jsonschema-form 的表单,该表单将从componentWillReceiveProps 上的props 接收枚举数组,并且应该更新处于该状态的模式。但即使我更新了状态和架构,表单也会更新。

Here 这是我的问题。基本上,枚举应该在点击时采用[one, two] 的值。

【问题讨论】:

    标签: forms reactjs jsonschema


    【解决方案1】:

    显然,分配给状态的对象不能很好地工作。最好的方法(对我有用)是使用最新的 Object.assign() 方法(here)。 Here 这是更新使用的工作解决方案

    this.setState({schema: Object.assign({}, this.state.schema, {
        properties:{list:{enum: ["1", "2"], enumNames: ["Name 1", "Name 2"]}}
    })})
    

    【讨论】:

    • 像魅力一样工作,动态矩形模式表单更新
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 2020-12-19
    • 2018-03-28
    相关资源
    最近更新 更多