Answer the question
In order to leave comments, you need to log in
How to use generics in Flow inside a React component object?
The code:
/* @flow */
import * as React from 'react';
type Props<T> = {
items: Array<T>
};
type State<T> = {
selectedItems: Array<T>
};
class MyComponent<T> extends React.Component<Props<T>, State<T>> {
state = {
selectedItems: []
};
renderListItem = ({ item }: { item: T }) => {
return item;
};
render() {
const {items} = this.props;
const renderedItems = items.map((item) => this.renderListItem({ item }))
return null;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question