(returnFiber, current, element)
| 8978 | var isArray$1 = Array.isArray; |
| 8979 | |
| 8980 | function coerceRef(returnFiber, current, element) { |
| 8981 | var mixedRef = element.ref; |
| 8982 | if (mixedRef !== null && typeof mixedRef !== 'function' && typeof mixedRef !== 'object') { |
| 8983 | { |
| 8984 | if (returnFiber.mode & StrictMode) { |
| 8985 | var componentName = getComponentName(returnFiber) || 'Component'; |
| 8986 | if (!didWarnAboutStringRefInStrictMode[componentName]) { |
| 8987 | warning(false, 'A string ref, "%s", has been found within a strict mode tree. ' + 'String refs are a source of potential bugs and should be avoided. ' + 'We recommend using createRef() instead.' + '\n%s' + '\n\nLearn more about using refs safely here:' + '\nhttps://fb.me/react-strict-mode-string-ref', mixedRef, getStackAddendumByWorkInProgressFiber(returnFiber)); |
| 8988 | didWarnAboutStringRefInStrictMode[componentName] = true; |
| 8989 | } |
| 8990 | } |
| 8991 | } |
| 8992 | |
| 8993 | if (element._owner) { |
| 8994 | var owner = element._owner; |
| 8995 | var inst = void 0; |
| 8996 | if (owner) { |
| 8997 | var ownerFiber = owner; |
| 8998 | !(ownerFiber.tag === ClassComponent) ? invariant(false, 'Stateless function components cannot have refs.') : void 0; |
| 8999 | inst = ownerFiber.stateNode; |
| 9000 | } |
| 9001 | !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; |
| 9002 | var stringRef = '' + mixedRef; |
| 9003 | // Check if previous string ref matches new string ref |
| 9004 | if (current !== null && current.ref !== null && current.ref._stringRef === stringRef) { |
| 9005 | return current.ref; |
| 9006 | } |
| 9007 | var ref = function (value) { |
| 9008 | var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs; |
| 9009 | if (value === null) { |
| 9010 | delete refs[stringRef]; |
| 9011 | } else { |
| 9012 | refs[stringRef] = value; |
| 9013 | } |
| 9014 | }; |
| 9015 | ref._stringRef = stringRef; |
| 9016 | return ref; |
| 9017 | } else { |
| 9018 | !(typeof mixedRef === 'string') ? invariant(false, 'Expected ref to be a function or a string.') : void 0; |
| 9019 | !element._owner ? invariant(false, 'Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a functional component\n2. You may be adding a ref to a component that was not created inside a component\'s render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.', mixedRef) : void 0; |
| 9020 | } |
| 9021 | } |
| 9022 | return mixedRef; |
| 9023 | } |
| 9024 | |
| 9025 | function throwOnInvalidObjectType(returnFiber, newChild) { |
| 9026 | if (returnFiber.type !== 'textarea') { |
no test coverage detected