MCPcopy
hub / github.com/ampproject/amphtml / forwardRef

Function forwardRef

src/preact/compat/internal.js:43–74  ·  view source on GitHub ↗
(Component)

Source from the content-addressed store, hash-verified

41 * @type {import('preact/compat').forwardRef}
42 */
43export const forwardRef = function (Component) {
44 /**
45 * @param {*} props
46 * @return {*}
47 */
48 function Forward(props) {
49 const {ref, ...clone} = props;
50 return Component(clone, ref);
51 }
52
53 // Is faithful react support necessary? This file should only be used in Preact mode,
54 // importers will directly import `React.forwardRef` in React builds.
55 Forward.$$typeof = REACT_FORWARD_SYMBOL;
56
57 // Preact pretends functional components are classical component instances,
58 // which are expected to have a render method.
59 Forward.render = Forward;
60
61 // https://github.com/preactjs/preact/blob/d78746c96245b70a83514a69ba4047e5dd0c7f54/compat/src/render.js#L26-L27
62 // Some libraries like `react-virtualized` explicitly check for this.
63 Forward.prototype.isReactComponent = true;
64
65 Forward.forwardRef_ = true;
66
67 if (!mode.isProd()) {
68 Forward.displayName = `ForwardRef(${
69 Component.displayName || Component.name
70 })`;
71 }
72
73 return /** @type {*} */ (Forward);
74};
75
76/**
77 * @type {typeof import('preact').toChildArray} children

Callers 15

test-slot.jsFile · 0.90
component.jsFile · 0.90
component.jsFile · 0.90
component.jsFile · 0.90
component.jsFile · 0.90
scroller.jsFile · 0.90
component.jsFile · 0.90
component.jsFile · 0.90
component.jsFile · 0.90
provider.jsFile · 0.90
component.jsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected