MCPcopy Create free account
hub / github.com/reactjs/react-rails / commitAttachRef

Function commitAttachRef

lib/assets/react-source/development/react.js:23701–23729  ·  view source on GitHub ↗
(finishedWork)

Source from the content-addressed store, hash-verified

23699 }
23700
23701 function commitAttachRef(finishedWork) {
23702 var ref = finishedWork.ref;
23703
23704 if (ref !== null) {
23705 var instance = finishedWork.stateNode;
23706 var instanceToUse;
23707
23708 switch (finishedWork.tag) {
23709 case HostComponent:
23710 instanceToUse = getPublicInstance(instance);
23711 break;
23712
23713 default:
23714 instanceToUse = instance;
23715 } // Moved outside to ensure DCE works with this flag
23716
23717 if (typeof ref === 'function') {
23718 ref(instanceToUse);
23719 } else {
23720 {
23721 if (!ref.hasOwnProperty('current')) {
23722 error('Unexpected ref object provided for %s. ' + 'Use either a ref-setter function or React.createRef().%s', getComponentName(finishedWork.type), getStackByFiberInDevAndProd(finishedWork));
23723 }
23724 }
23725
23726 ref.current = instanceToUse;
23727 }
23728 }
23729 }
23730
23731 function commitDetachRef(current) {
23732 var currentRef = current.ref;

Callers 1

commitLayoutEffectsFunction · 0.85

Calls 5

getPublicInstanceFunction · 0.85
refFunction · 0.85
errorFunction · 0.70
getComponentNameFunction · 0.70

Tested by

no test coverage detected