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

Function commitAttachRef

dash/deps/react-dom@18.2.0.js:23633–23678  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

23631 }
23632
23633 function commitAttachRef(finishedWork) {
23634 var ref = finishedWork.ref;
23635
23636 if (ref !== null) {
23637 var instance = finishedWork.stateNode;
23638 var instanceToUse;
23639
23640 switch (finishedWork.tag) {
23641 case HostComponent:
23642 instanceToUse = getPublicInstance(instance);
23643 break;
23644
23645 default:
23646 instanceToUse = instance;
23647 } // Moved outside to ensure DCE works with this flag
23648
23649 if (typeof ref === 'function') {
23650 var retVal;
23651
23652 if ( finishedWork.mode & ProfileMode) {
23653 try {
23654 startLayoutEffectTimer();
23655 retVal = ref(instanceToUse);
23656 } finally {
23657 recordLayoutEffectDuration(finishedWork);
23658 }
23659 } else {
23660 retVal = ref(instanceToUse);
23661 }
23662
23663 {
23664 if (typeof retVal === 'function') {
23665 error('Unexpected return value from a callback ref in %s. ' + 'A callback ref should not return a function.', getComponentNameFromFiber(finishedWork));
23666 }
23667 }
23668 } else {
23669 {
23670 if (!ref.hasOwnProperty('current')) {
23671 error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().', getComponentNameFromFiber(finishedWork));
23672 }
23673 }
23674
23675 ref.current = instanceToUse;
23676 }
23677 }
23678 }
23679
23680 function detachFiberMutation(fiber) {
23681 // 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…