MCPcopy Create free account
hub / github.com/jamiebuilds/create-react-context / componentWillReceiveProps

Method componentWillReceiveProps

src/implementation.js:88–117  ·  view source on GitHub ↗
(nextProps)

Source from the content-addressed store, hash-verified

86 }
87
88 componentWillReceiveProps(nextProps) {
89 if (this.props.value !== nextProps.value) {
90 let oldValue = this.props.value;
91 let newValue = nextProps.value;
92 let changedBits: number;
93
94 if (objectIs(oldValue, newValue)) {
95 changedBits = 0; // No change
96 } else {
97 changedBits =
98 typeof calculateChangedBits === 'function'
99 ? calculateChangedBits(oldValue, newValue)
100 : MAX_SIGNED_31_BIT_INT;
101 if (process.env.NODE_ENV !== 'production') {
102 warning(
103 (changedBits & MAX_SIGNED_31_BIT_INT) === changedBits,
104 'calculateChangedBits: Expected the return value to be a ' +
105 '31-bit integer. Instead received: %s',
106 changedBits
107 );
108 }
109
110 changedBits |= 0;
111
112 if (changedBits !== 0) {
113 this.emitter.set(nextProps.value, changedBits);
114 }
115 }
116 }
117 }
118
119 render() {
120 return this.props.children;

Callers

nothing calls this directly

Calls 1

objectIsFunction · 0.85

Tested by

no test coverage detected