(Component)
| 41 | * @type {import('preact/compat').forwardRef} |
| 42 | */ |
| 43 | export 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 |
no outgoing calls
no test coverage detected