如何使用Flow在React中添加多态道具

时间:2017-03-13 12:03:04

标签: javascript reactjs flowtype

如何将多态道具添加到React组件?

我尝试了以下内容,但结果是:

T. This type is incompatible with some incompatible instantiation of T

示例:

/* @flow */
import React from 'react';

type Props<T> = {
  promise: () => Promise<T>
}

export default class Async<T> extends React.Component {
    props: Props<T>;
}

1 个答案:

答案 0 :(得分:2)

奇怪的错误,你可以试试这个

/* @flow */
import React from 'react';

type Props<T> = {
  promise: () => Promise<T>
}

export default class Async<T> extends React.Component<*, Props<T>, *> {}