React js源代码

时间:2018-06-21 14:24:26

标签: reactjs

我正在阅读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>到底是什么?这是函数名称吗?为什么看起来像这样?

1 个答案:

答案 0 :(得分:1)

这是在flow中定义通用函数的方式。看看here