MCPcopy
hub / github.com/preactjs/preact / forwardRef

Function forwardRef

compat/src/forwardRef.js:26–44  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

24 * @returns {import('./internal').FunctionComponent}
25 */
26export function forwardRef(fn) {
27 function Forwarded(props) {
28 let clone = assign({}, props);
29 delete clone.ref;
30 return fn(clone, props.ref || null);
31 }
32
33 // mobx-react checks for this being present
34 Forwarded.$$typeof = REACT_FORWARD_SYMBOL;
35 // mobx-react heavily relies on implementation details.
36 // It expects an object here with a `render` property,
37 // and prototype.render will fail. Without this
38 // mobx-react throws.
39 Forwarded.render = fn;
40
41 Forwarded.prototype.isReactComponent = Forwarded._forwarded = true;
42 Forwarded.displayName = 'ForwardRef(' + (fn.displayName || fn.name) + ')';
43 return Forwarded;
44}

Callers 3

mobx.jsxFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…