Это определение типа SFC
: ожидается, что вы вернете ReactElement
или null
, а вы возвращаете Element[]
.
type SFC<P = {}> = FunctionComponent<P>;
interface FunctionComponent<P = {}> {
(props: PropsWithChildren<P>, context?: any): ReactElement | null;
...
}
Вы можете использовать Реагироватьфрагменты :
const TodoList: React.SFC<Props> = ({ items, children }) => {
return (
<>
{items.map((item: Item) => (
<div key={item.id}>{item.id}</div>
))}
</>
);
};