MCPcopy Create free account
hub / github.com/plotly/dash / commitAttachRef

Function commitAttachRef

dash/deps/react-dom@18.3.1.js:23672–23717  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

23670 }
23671
23672 function commitAttachRef(finishedWork) {
23673 var ref = finishedWork.ref;
23674
23675 if (ref !== null) {
23676 var instance = finishedWork.stateNode;
23677 var instanceToUse;
23678
23679 switch (finishedWork.tag) {
23680 case HostComponent:
23681 instanceToUse = getPublicInstance(instance);
23682 break;
23683
23684 default:
23685 instanceToUse = instance;
23686 } // Moved outside to ensure DCE works with this flag
23687
23688 if (typeof ref === 'function') {
23689 var retVal;
23690
23691 if ( finishedWork.mode & ProfileMode) {
23692 try {
23693 startLayoutEffectTimer();
23694 retVal = ref(instanceToUse);
23695 } finally {
23696 recordLayoutEffectDuration(finishedWork);
23697 }
23698 } else {
23699 retVal = ref(instanceToUse);
23700 }
23701
23702 {
23703 if (typeof retVal === 'function') {
23704 error('Unexpected return value from a callback ref in %s. ' + 'A callback ref should not return a function.', getComponentNameFromFiber(finishedWork));
23705 }
23706 }
23707 } else {
23708 {
23709 if (!ref.hasOwnProperty('current')) {
23710 error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().', getComponentNameFromFiber(finishedWork));
23711 }
23712 }
23713
23714 ref.current = instanceToUse;
23715 }
23716 }
23717 }
23718
23719 function detachFiberMutation(fiber) {
23720 // Cut off the return pointer to disconnect it from the tree.

Callers 2

safelyAttachRefFunction · 0.70

Calls 6

getPublicInstanceFunction · 0.70
startLayoutEffectTimerFunction · 0.70
refFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…