(workInProgress, ctor, props)
| 18163 | } |
| 18164 | |
| 18165 | function constructClassInstance(workInProgress, ctor, props) { |
| 18166 | var isLegacyContextConsumer = false; |
| 18167 | var unmaskedContext = emptyContextObject; |
| 18168 | var context = emptyContextObject; |
| 18169 | var contextType = ctor.contextType; |
| 18170 | |
| 18171 | { |
| 18172 | if ('contextType' in ctor) { |
| 18173 | var isValid = // Allow null for conditional declaration |
| 18174 | contextType === null || contextType !== undefined && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === undefined; // Not a <Context.Consumer> |
| 18175 | |
| 18176 | if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { |
| 18177 | didWarnAboutInvalidateContextType.add(ctor); |
| 18178 | var addendum = ''; |
| 18179 | |
| 18180 | if (contextType === undefined) { |
| 18181 | 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.'; |
| 18182 | } else if (typeof contextType !== 'object') { |
| 18183 | addendum = ' However, it is set to a ' + typeof contextType + '.'; |
| 18184 | } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { |
| 18185 | addendum = ' Did you accidentally pass the Context.Provider instead?'; |
| 18186 | } else if (contextType._context !== undefined) { |
| 18187 | // <Context.Consumer> |
| 18188 | addendum = ' Did you accidentally pass the Context.Consumer instead?'; |
| 18189 | } else { |
| 18190 | addendum = ' However, it is set to an object with keys {' + Object.keys(contextType).join(', ') + '}.'; |
| 18191 | } |
| 18192 | |
| 18193 | error('%s defines an invalid contextType. ' + 'contextType should point to the Context object returned by React.createContext().%s', getComponentNameFromType(ctor) || 'Component', addendum); |
| 18194 | } |
| 18195 | } |
| 18196 | } |
| 18197 | |
| 18198 | if (typeof contextType === 'object' && contextType !== null) { |
| 18199 | context = readContext(contextType); |
| 18200 | } else { |
| 18201 | unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); |
| 18202 | var contextTypes = ctor.contextTypes; |
| 18203 | isLegacyContextConsumer = contextTypes !== null && contextTypes !== undefined; |
| 18204 | context = isLegacyContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; |
| 18205 | } |
| 18206 | |
| 18207 | var instance = new ctor(props, context); // Instantiate twice to help detect side-effects. |
| 18208 | |
| 18209 | { |
| 18210 | if ( workInProgress.mode & StrictLegacyMode) { |
| 18211 | setIsStrictModeForDevtools(true); |
| 18212 | |
| 18213 | try { |
| 18214 | instance = new ctor(props, context); // eslint-disable-line no-new |
| 18215 | } finally { |
| 18216 | setIsStrictModeForDevtools(false); |
| 18217 | } |
| 18218 | } |
| 18219 | } |
| 18220 | |
| 18221 | var state = workInProgress.memoizedState = instance.state !== null && instance.state !== undefined ? instance.state : null; |
| 18222 | adoptClassInstance(workInProgress, instance); |
no test coverage detected
searching dependent graphs…