(current, workInProgress, renderExpirationTime)
| 10337 | } |
| 10338 | |
| 10339 | function updateContextProvider(current, workInProgress, renderExpirationTime) { |
| 10340 | var providerType = workInProgress.type; |
| 10341 | var context = providerType.context; |
| 10342 | |
| 10343 | var newProps = workInProgress.pendingProps; |
| 10344 | var oldProps = workInProgress.memoizedProps; |
| 10345 | |
| 10346 | if (hasLegacyContextChanged()) { |
| 10347 | // Normally we can bail out on props equality but if context has changed |
| 10348 | // we don't do the bailout and we have to reuse existing props instead. |
| 10349 | } else if (oldProps === newProps) { |
| 10350 | workInProgress.stateNode = 0; |
| 10351 | pushProvider(workInProgress); |
| 10352 | return bailoutOnAlreadyFinishedWork(current, workInProgress); |
| 10353 | } |
| 10354 | |
| 10355 | var newValue = newProps.value; |
| 10356 | workInProgress.memoizedProps = newProps; |
| 10357 | |
| 10358 | var changedBits = void 0; |
| 10359 | if (oldProps === null) { |
| 10360 | // Initial render |
| 10361 | changedBits = MAX_SIGNED_31_BIT_INT; |
| 10362 | } else { |
| 10363 | if (oldProps.value === newProps.value) { |
| 10364 | // No change. Bailout early if children are the same. |
| 10365 | if (oldProps.children === newProps.children) { |
| 10366 | workInProgress.stateNode = 0; |
| 10367 | pushProvider(workInProgress); |
| 10368 | return bailoutOnAlreadyFinishedWork(current, workInProgress); |
| 10369 | } |
| 10370 | changedBits = 0; |
| 10371 | } else { |
| 10372 | var oldValue = oldProps.value; |
| 10373 | // Use Object.is to compare the new context value to the old value. |
| 10374 | // Inlined Object.is polyfill. |
| 10375 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is |
| 10376 | if (oldValue === newValue && (oldValue !== 0 || 1 / oldValue === 1 / newValue) || oldValue !== oldValue && newValue !== newValue // eslint-disable-line no-self-compare |
| 10377 | ) { |
| 10378 | // No change. Bailout early if children are the same. |
| 10379 | if (oldProps.children === newProps.children) { |
| 10380 | workInProgress.stateNode = 0; |
| 10381 | pushProvider(workInProgress); |
| 10382 | return bailoutOnAlreadyFinishedWork(current, workInProgress); |
| 10383 | } |
| 10384 | changedBits = 0; |
| 10385 | } else { |
| 10386 | changedBits = typeof context._calculateChangedBits === 'function' ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT; |
| 10387 | { |
| 10388 | warning((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits, 'calculateChangedBits: Expected the return value to be a ' + '31-bit integer. Instead received: %s', changedBits); |
| 10389 | } |
| 10390 | changedBits |= 0; |
| 10391 | |
| 10392 | if (changedBits === 0) { |
| 10393 | // No change. Bailout early if children are the same. |
| 10394 | if (oldProps.children === newProps.children) { |
| 10395 | workInProgress.stateNode = 0; |
| 10396 | pushProvider(workInProgress); |
no test coverage detected