(workInProgress, ctor, newProps, renderExpirationTime)
| 16690 | |
| 16691 | |
| 16692 | function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { |
| 16693 | { |
| 16694 | checkClassInstance(workInProgress, ctor, newProps); |
| 16695 | } |
| 16696 | |
| 16697 | var instance = workInProgress.stateNode; |
| 16698 | instance.props = newProps; |
| 16699 | instance.state = workInProgress.memoizedState; |
| 16700 | instance.refs = emptyRefsObject; |
| 16701 | initializeUpdateQueue(workInProgress); |
| 16702 | var contextType = ctor.contextType; |
| 16703 | |
| 16704 | if (typeof contextType === 'object' && contextType !== null) { |
| 16705 | instance.context = readContext(contextType); |
| 16706 | } else { |
| 16707 | var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); |
| 16708 | instance.context = getMaskedContext(workInProgress, unmaskedContext); |
| 16709 | } |
| 16710 | |
| 16711 | { |
| 16712 | if (instance.state === newProps) { |
| 16713 | var componentName = getComponentName(ctor) || 'Component'; |
| 16714 | |
| 16715 | if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { |
| 16716 | didWarnAboutDirectlyAssigningPropsToState.add(componentName); |
| 16717 | |
| 16718 | error('%s: It is not recommended to assign props directly to state ' + "because updates to props won't be reflected in state. " + 'In most cases, it is better to use props directly.', componentName); |
| 16719 | } |
| 16720 | } |
| 16721 | |
| 16722 | if (workInProgress.mode & StrictMode) { |
| 16723 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); |
| 16724 | } |
| 16725 | |
| 16726 | { |
| 16727 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); |
| 16728 | } |
| 16729 | } |
| 16730 | |
| 16731 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); |
| 16732 | instance.state = workInProgress.memoizedState; |
| 16733 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps; |
| 16734 | |
| 16735 | if (typeof getDerivedStateFromProps === 'function') { |
| 16736 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); |
| 16737 | instance.state = workInProgress.memoizedState; |
| 16738 | } // In order to support react-lifecycles-compat polyfilled components, |
| 16739 | // Unsafe lifecycles should not be invoked for components using the new APIs. |
| 16740 | |
| 16741 | |
| 16742 | if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { |
| 16743 | callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's |
| 16744 | // process them now. |
| 16745 | |
| 16746 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); |
| 16747 | instance.state = workInProgress.memoizedState; |
| 16748 | } |
| 16749 |
no test coverage detected