MCPcopy Create free account
hub / github.com/danielstocks/react-sortable / coerceRef

Function coerceRef

bundle.js:7067–7069  ·  view source on GitHub ↗
(current,element)

Source from the content-addressed store, hash-verified

7065// The Symbol used to tag the ReactElement type. If there is no native Symbol
7066// nor polyfill, then a plain number is used for performance.
7067var REACT_ELEMENT_TYPE=typeof Symbol==='function'&&Symbol['for']&&Symbol['for']('react.element')||0xeac7;function getIteratorFn(maybeIterable){if(maybeIterable===null||typeof maybeIterable==='undefined'){return null;}var iteratorFn=ITERATOR_SYMBOL&&maybeIterable[ITERATOR_SYMBOL]||maybeIterable[FAUX_ITERATOR_SYMBOL];if(typeof iteratorFn==='function'){return iteratorFn;}return null;}function coerceRef(current,element){var mixedRef=element.ref;if(mixedRef!==null&&typeof mixedRef!=='function'){if(element._owner){var owner=element._owner;var inst=void 0;if(owner){if(typeof owner.tag==='number'){var ownerFiber=owner;!(ownerFiber.tag===ClassComponent$7)?invariant(false,'Stateless function components cannot have refs.'):void 0;inst=ownerFiber.stateNode;}else{// Stack
7068inst=owner.getPublicInstance();}}!inst?invariant(false,'Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.',mixedRef):void 0;var stringRef=''+mixedRef;// Check if previous string ref matches new string ref
7069if(current!==null&&current.ref!==null&&current.ref._stringRef===stringRef){return current.ref;}var ref=function ref(value){var refs=inst.refs===emptyObject?inst.refs={}:inst.refs;if(value===null){delete refs[stringRef];}else{refs[stringRef]=value;}};ref._stringRef=stringRef;return ref;}else{!(typeof mixedRef==='string')?invariant(false,'Expected ref to be a function or a string.'):void 0;!element._owner?invariant(false,'Element ref was specified as a string (%s) but no owner was set. You may have multiple copies of React loaded. (details: https://fb.me/react-refs-must-have-owner).',mixedRef):void 0;}}return mixedRef;}function throwOnInvalidObjectType(returnFiber,newChild){if(returnFiber.type!=='textarea'){var addendum='';{addendum=' If you meant to render a collection of children, use an array '+'instead.'+(getCurrentFiberStackAddendum$5()||'');}invariant(false,'Objects are not valid as a React child (found: %s).%s',Object.prototype.toString.call(newChild)==='[object Object]'?'object with keys {'+Object.keys(newChild).join(', ')+'}':newChild,addendum);}}function warnOnFunctionType(){warning$24(false,'Functions are not valid as a React child. This may happen if '+'you return a Component instead of <Component /> from render. '+'Or maybe you meant to call this function rather than return it.%s',getCurrentFiberStackAddendum$5()||'');}// This wrapper function exists because I expect to clone the code in each path
7070// to be able to optimize each path individually by branching early. This needs
7071// a compiler or we can do it manually. Helpers that don't need this branching
7072// live outside of this function.

Callers 3

updateElementFunction · 0.85
createChildFunction · 0.85
reconcileSingleElementFunction · 0.85

Calls 1

invariantFunction · 0.70

Tested by

no test coverage detected