1 | import * as PropTypes from 'prop-types';
|
2 | import * as React from 'react';
|
3 | import * as ReactIs from 'react-is';
|
4 | import RefFindNode from './RefFindNode';
|
5 | import RefForward from './RefForward';
|
6 | import { refPropType } from './types';
|
7 |
|
8 | var Ref = function Ref(props) {
|
9 | var children = props.children,
|
10 | innerRef = props.innerRef;
|
11 | var child = React.Children.only(children);
|
12 | var ElementType = ReactIs.isForwardRef(child) ? RefForward : RefFindNode;
|
13 | return React.createElement(ElementType, {
|
14 | innerRef: innerRef
|
15 | }, child);
|
16 | };
|
17 |
|
18 | Ref.displayName = 'Ref';
|
19 |
|
20 | if (process.env.NODE_ENV !== 'production') {
|
21 | Ref.propTypes = {
|
22 | children: PropTypes.element.isRequired,
|
23 | innerRef: refPropType.isRequired
|
24 | };
|
25 | }
|
26 |
|
27 | export default Ref; |
\ | No newline at end of file |