(workInProgress, props)
| 7599 | } |
| 7600 | |
| 7601 | function constructClassInstance(workInProgress, props) { |
| 7602 | var ctor = workInProgress.type; |
| 7603 | var unmaskedContext = getUnmaskedContext(workInProgress); |
| 7604 | var needsContext = isContextConsumer(workInProgress); |
| 7605 | var context = needsContext ? getMaskedContext(workInProgress, unmaskedContext) : emptyObject; |
| 7606 | |
| 7607 | // Instantiate twice to help detect side-effects. |
| 7608 | if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) { |
| 7609 | new ctor(props, context); // eslint-disable-line no-new |
| 7610 | } |
| 7611 | |
| 7612 | var instance = new ctor(props, context); |
| 7613 | var state = instance.state !== null && instance.state !== undefined ? instance.state : null; |
| 7614 | adoptClassInstance(workInProgress, instance); |
| 7615 | |
| 7616 | { |
| 7617 | if (typeof ctor.getDerivedStateFromProps === 'function') { |
| 7618 | if (state === null) { |
| 7619 | var componentName = getComponentName(workInProgress) || 'Component'; |
| 7620 | if (!didWarnAboutUninitializedState[componentName]) { |
| 7621 | warning(false, '%s: Did not properly initialize state during construction. ' + 'Expected state to be an object, but it was %s.', componentName, instance.state === null ? 'null' : 'undefined'); |
| 7622 | didWarnAboutUninitializedState[componentName] = true; |
| 7623 | } |
| 7624 | } |
| 7625 | |
| 7626 | // If getDerivedStateFromProps() is defined, "unsafe" lifecycles won't be called. |
| 7627 | // Warn about these lifecycles if they are present. |
| 7628 | // Don't warn about react-lifecycles-compat polyfilled methods though. |
| 7629 | var foundWillMountName = null; |
| 7630 | var foundWillReceivePropsName = null; |
| 7631 | var foundWillUpdateName = null; |
| 7632 | if (typeof instance.componentWillMount === 'function' && instance.componentWillMount.__suppressDeprecationWarning !== true) { |
| 7633 | foundWillMountName = 'componentWillMount'; |
| 7634 | } else if (typeof instance.UNSAFE_componentWillMount === 'function') { |
| 7635 | foundWillMountName = 'UNSAFE_componentWillMount'; |
| 7636 | } |
| 7637 | if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { |
| 7638 | foundWillReceivePropsName = 'componentWillReceiveProps'; |
| 7639 | } else if (typeof instance.UNSAFE_componentWillReceiveProps === 'function') { |
| 7640 | foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps'; |
| 7641 | } |
| 7642 | if (typeof instance.componentWillUpdate === 'function') { |
| 7643 | foundWillUpdateName = 'componentWillUpdate'; |
| 7644 | } else if (typeof instance.UNSAFE_componentWillUpdate === 'function') { |
| 7645 | foundWillUpdateName = 'UNSAFE_componentWillUpdate'; |
| 7646 | } |
| 7647 | if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) { |
| 7648 | var _componentName = getComponentName(workInProgress) || 'Component'; |
| 7649 | if (!didWarnAboutLegacyLifecyclesAndDerivedState[_componentName]) { |
| 7650 | warning(false, 'Unsafe legacy lifecycles will not be called for components using ' + 'the new getDerivedStateFromProps() API.\n\n' + '%s uses getDerivedStateFromProps() but also contains the following legacy lifecycles:' + '%s%s%s\n\n' + 'The above lifecycles should be removed. Learn more about this warning here:\n' + 'https://fb.me/react-async-component-lifecycle-hooks', _componentName, foundWillMountName !== null ? '\n ' + foundWillMountName : '', foundWillReceivePropsName !== null ? '\n ' + foundWillReceivePropsName : '', foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : ''); |
| 7651 | didWarnAboutLegacyLifecyclesAndDerivedState[_componentName] = true; |
| 7652 | } |
| 7653 | } |
| 7654 | } |
| 7655 | } |
| 7656 | |
| 7657 | workInProgress.memoizedState = state; |
| 7658 |
no test coverage detected