MCPcopy Index your code
hub / github.com/plotly/dash / mountClassInstance

Function mountClassInstance

dash/deps/react-dom@18.2.0.js:14457–14527  ·  view source on GitHub ↗
(workInProgress, ctor, newProps, renderLanes)

Source from the content-addressed store, hash-verified

14455
14456
14457 function mountClassInstance(workInProgress, ctor, newProps, renderLanes) {
14458 {
14459 checkClassInstance(workInProgress, ctor, newProps);
14460 }
14461
14462 var instance = workInProgress.stateNode;
14463 instance.props = newProps;
14464 instance.state = workInProgress.memoizedState;
14465 instance.refs = emptyRefsObject;
14466 initializeUpdateQueue(workInProgress);
14467 var contextType = ctor.contextType;
14468
14469 if (typeof contextType === 'object' && contextType !== null) {
14470 instance.context = readContext(contextType);
14471 } else {
14472 var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
14473 instance.context = getMaskedContext(workInProgress, unmaskedContext);
14474 }
14475
14476 {
14477 if (instance.state === newProps) {
14478 var componentName = getComponentNameFromType(ctor) || 'Component';
14479
14480 if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
14481 didWarnAboutDirectlyAssigningPropsToState.add(componentName);
14482
14483 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);
14484 }
14485 }
14486
14487 if (workInProgress.mode & StrictLegacyMode) {
14488 ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, instance);
14489 }
14490
14491 {
14492 ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress, instance);
14493 }
14494 }
14495
14496 instance.state = workInProgress.memoizedState;
14497 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
14498
14499 if (typeof getDerivedStateFromProps === 'function') {
14500 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
14501 instance.state = workInProgress.memoizedState;
14502 } // In order to support react-lifecycles-compat polyfilled components,
14503 // Unsafe lifecycles should not be invoked for components using the new APIs.
14504
14505
14506 if (typeof ctor.getDerivedStateFromProps !== 'function' && typeof instance.getSnapshotBeforeUpdate !== 'function' && (typeof instance.UNSAFE_componentWillMount === 'function' || typeof instance.componentWillMount === 'function')) {
14507 callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's
14508 // process them now.
14509
14510 processUpdateQueue(workInProgress, newProps, instance, renderLanes);
14511 instance.state = workInProgress.memoizedState;
14512 }
14513
14514 if (typeof instance.componentDidMount === 'function') {

Callers 3

updateClassComponentFunction · 0.70

Calls 11

checkClassInstanceFunction · 0.70
initializeUpdateQueueFunction · 0.70
readContextFunction · 0.70
getUnmaskedContextFunction · 0.70
getMaskedContextFunction · 0.70
getComponentNameFromTypeFunction · 0.70
errorFunction · 0.70
callComponentWillMountFunction · 0.70
processUpdateQueueFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…