MCPcopy
hub / github.com/NervJS/nerv / shouldComponentUpdate

Function shouldComponentUpdate

packages/nerv/src/memo.ts:7–16  ·  view source on GitHub ↗
(this: Component, nextProps)

Source from the content-addressed store, hash-verified

5
6export function memo (component: Function, propsAreEqual?: Function) {
7 function shouldComponentUpdate (this: Component, nextProps): boolean {
8 const prevRef = this.props.ref
9 const nextRef = nextProps.ref
10 if (prevRef !== nextRef) {
11 Ref.detach(this.vnode, prevRef, this.dom)
12 Ref.attach(this.vnode, nextRef, this.dom)
13 return true
14 }
15 return isFunction(propsAreEqual) ? !propsAreEqual(this.props, nextProps) : !shallowEqual(this.props, nextProps)
16 }
17
18 function Memoed (this: Component, props) {
19 this.shouldComponentUpdate = shouldComponentUpdate

Callers

nothing calls this directly

Calls 2

isFunctionFunction · 0.90
shallowEqualFunction · 0.90

Tested by

no test coverage detected