我正在阅读react.js
的源代码,并且在forwardRef.js
内部遇到了此函数。无法理解函数名称部分,
export default function forwardRef<Props, ElementType: React$ElementType>(
render: (props: Props, ref: React$ElementRef<ElementType>) => React$Node,
) {
if (__DEV__) {
warning(
typeof render === 'function',
'forwardRef requires a render function but was given %s.',
render === null ? 'null' : typeof render,
);
if (render != null) {
warning(
render.defaultProps == null && render.propTypes == null,
'forwardRef render functions do not support propTypes or defaultProps. ' +
'Did you accidentally pass a React component?',
);
}
}
forwardRef<Props, ElementType: React$ElementType>
到底是什么?这是函数名称吗?为什么看起来像这样?