react-component-debounce icon indicating copy to clipboard operation
react-component-debounce copied to clipboard

感觉 shouldUpdate 存在豪无意义

Open jiajianrong opened this issue 6 years ago • 0 comments

先赞,深度好文

不过我感觉 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 也意义不大吧?

jiajianrong avatar Mar 21 '18 04:03 jiajianrong