Redux-form - 有没有办法知道哪些字段已更改? (更新和补丁)
Redux-form - Is there a way to know what fields have been changed? (update & PATCH)
使用 redux-form
更新实体时,我想知道更改了哪些字段,以便仅对这些字段使用 PATCH HTTP 请求。 (并没有发送整个表格)
有内置的方法吗?我正在查看文档,但似乎还没有任何选择。
每个字段都有一个 "dirty" 属性。似乎是您要查找的内容:
true if the current value is different from the initialized value, false otherwise.
http://redux-form.com/6.5.0/docs/api/Field.md/#-dirty-boolean-
您需要保留所有 "dirty" 字段的列表,但这应该可以通过 .filter()
你是在提交时做的吗?您可以手动将 values
与 this.props.initialValues
进行比较以确定更改后的值。
使用 redux-form
更新实体时,我想知道更改了哪些字段,以便仅对这些字段使用 PATCH HTTP 请求。 (并没有发送整个表格)
有内置的方法吗?我正在查看文档,但似乎还没有任何选择。
每个字段都有一个 "dirty" 属性。似乎是您要查找的内容:
true if the current value is different from the initialized value, false otherwise.
http://redux-form.com/6.5.0/docs/api/Field.md/#-dirty-boolean-
您需要保留所有 "dirty" 字段的列表,但这应该可以通过 .filter()
你是在提交时做的吗?您可以手动将 values
与 this.props.initialValues
进行比较以确定更改后的值。