Skip to content

感觉 shouldUpdate 存在豪无意义 #1

@jiajianrong

Description

@jiajianrong

先赞,深度好文

不过我感觉 ReactFormFieldDebouncecomponentWillReceiveProps 方法的条件判断似乎可以省略了

        if (shouldUpdate([theOptions.valuePropName], this.props, nextProps)) {
          if (this.lastValue !== nextProps[theOptions.valuePropName]) {
            this.valueUpdateDebounce(nextProps[theOptions.valuePropName]);
          }
        }

因为你的 shouldUpdate 实现是对比遍历 this.propsnextProps,似乎可以交给react自己的diff,效果也一样吧?

去掉上面两个if判断,直接使用 this.valueUpdateDebounce,即便最坏的情况,最多也就影响一个表单域的性能

同样,shouldComponentUpdate 里的 shouldUpdate 也意义不大吧?

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