(workInProgress, ctor, props)
| 16524 | } |
| 16525 | |
| 16526 | function constructClassInstance(workInProgress, ctor, props) { |
| 16527 | var isLegacyContextConsumer = false; |
| 16528 | var unmaskedContext = emptyContextObject; |
| 16529 | var context = emptyContextObject; |
| 16530 | var contextType = ctor.contextType; |
| 16531 | |
| 16532 | { |
| 16533 | if ('contextType' in ctor) { |
| 16534 | var isValid = // Allow null for conditional declaration |
| 16535 | contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> |
| 16536 | |
| 16537 | if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { |
| 16538 | didWarnAboutInvalidateContextType.add(ctor); |
| 16539 | var addendum = ''; |
| 16540 | |
| 16541 | if (contextType === undefined) { |
| 16542 | addendum = ' However, it is set to undefined. ' + 'This can be caused by a typo or by mixing up named and default imports. ' + 'This can also happen due to a circular dependency, so ' + 'try moving the createContext() call to a separate file.'; |
| 16543 | } else if (typeof contextType !== 'object') { |
| 16544 | addendum = ' However, it is set to a ' + typeof contextType + '.'; |
| 16545 | } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { |
| 16546 | addendum = ' Did you accidentally pass the Context.Provider instead?'; |
| 16547 | } else if (contextType._context !== undefined) { |
| 16548 | // <Context.Consumer> |
| 16549 | addendum = ' Did you accidentally pass the Context.Consumer instead?'; |
| 16550 | } else { |
| 16551 | addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; |
| 16552 | } |
| 16553 | |
| 16554 | error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentName(ctor) || 'Component', addendum); |
| 16555 | } |
| 16556 | } |
| 16557 | } |
| 16558 | |
| 16559 | if (typeof contextType === 'object' && contextType !== null) { |
| 16560 | context = readContext(contextType); |
| 16561 | } else { |
| 16562 | unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); |
| 16563 | var contextTypes = ctor.contextTypes; |
| 16564 | isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; |
| 16565 | context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; |
| 16566 | } // Instantiate twice to help detect side-effects. |
| 16567 | |
| 16568 | |
| 16569 | { |
| 16570 | if ( workInProgress.mode & StrictMode) { |
| 16571 | new ctor(props, context); // eslint-disable-line no-new |
| 16572 | } |
| 16573 | } |
| 16574 | |
| 16575 | var instance = new ctor(props, context); |
| 16576 | var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; |
| 16577 | adoptClassInstance(workInProgress, instance); |
| 16578 | |
| 16579 | { |
| 16580 | if (typeof ctor.getDerivedStateFromProps === 'function' && state === null) { |
| 16581 | var componentName = getComponentName(ctor) || 'Component'; |
| 16582 | |
| 16583 | if (!didWarnAboutUninitializedState.has(componentName)) { |
no test coverage detected