import { inherit } from "./util";
import { Component } from "./Component";
import { shallowEqual } from "./shallowEqual";

export function PureComponent(props, context) {
    Component.call(this, props, context);
}

let fn = inherit(PureComponent, Component);

fn.shouldComponentUpdate = function shallowCompare(nextProps, nextState) {
    var a = shallowEqual(this.props, nextProps);
    var b = shallowEqual(this.state, nextState);
    return !a || !b;
};
fn.isPureComponent = true;

 

相关文章:

  • 2021-05-25
  • 2021-11-13
  • 2021-10-25
  • 2022-03-03
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-04-26
猜你喜欢
  • 2022-12-23
  • 2022-02-10
  • 2022-01-08
  • 2021-11-07
  • 2021-09-11
  • 2021-07-15
  • 2021-09-04
相关资源
相似解决方案