(workInProgress, ctor, newProps, renderExpirationTime)
| 13130 | |
| 13131 | |
| 13132 | function mountClassInstance(workInProgress, ctor, newProps, renderExpirationTime) { |
| 13133 | { |
| 13134 | checkClassInstance(workInProgress, ctor, newProps); |
| 13135 | } |
| 13136 | |
| 13137 | var instance = workInProgress.stateNode; |
| 13138 | instance.props = newProps; |
| 13139 | instance.state = workInProgress.memoizedState; |
| 13140 | instance.refs = emptyRefsObject; |
| 13141 | initializeUpdateQueue(workInProgress); |
| 13142 | var contextType = ctor.contextType; |
| 13143 | |
| 13144 | if (typeof contextType === 'object' && contextType !== null) { |
| 13145 | instance.context = readContext(contextType); |
| 13146 | } else { |
| 13147 | var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); |
| 13148 | instance.context = getMaskedContext(workInProgress, unmaskedContext); |
| 13149 | } |
| 13150 | |
| 13151 | { |
| 13152 | if (instance.state === newProps) { |
| 13153 | var componentName = getComponentName(ctor) || 'Component'; |
| 13154 | |
| 13155 | if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { |
| 13156 | didWarnAboutDirectlyAssigningPropsToState.add(componentName); |
| 13157 | |
| 13158 | 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); |
| 13159 | } |
| 13160 | } |
| 13161 | |
| 13162 | if (workInProgress.mode & StrictMode) { |
| 13163 | ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance); |
| 13164 | } |
| 13165 | |
| 13166 | { |
| 13167 | ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance); |
| 13168 | } |
| 13169 | } |
| 13170 | |
| 13171 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); |
| 13172 | instance.state = workInProgress.memoizedState; |
| 13173 | var getDerivedStateFromProps = ctor.getDerivedStateFromProps; |
| 13174 | |
| 13175 | if (typeof getDerivedStateFromProps === 'function') { |
| 13176 | applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps); |
| 13177 | instance.state = workInProgress.memoizedState; |
| 13178 | } // In order to support react-lifecycles-compat polyfilled components, |
| 13179 | // Unsafe lifecycles should not be invoked for components using the new APIs. |
| 13180 | |
| 13181 | |
| 13182 | if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) { |
| 13183 | callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's |
| 13184 | // process them now. |
| 13185 | |
| 13186 | processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); |
| 13187 | instance.state = workInProgress.memoizedState; |
| 13188 | } |
| 13189 |
no test coverage detected