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

[英]How to add polymorphic props in React using Flow


How can I add polymorphic props to a React component?

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

I have tried the following, but it results in:

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

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

T.这种类型与T的一些不兼容的实例化不兼容

Example:

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

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

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

1 个解决方案

#1


2  

Strange error, you can try this instead

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

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

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

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

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2017/03/13/fae6e3b68f51988578f57f72f16a2771.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告