Я пытаюсь использовать компонент Typography из material-ui с TypeScript, но получаю эту странную ошибку
TypeScript error: Type 'string' is not assignable to type 'ComponentClass<HTMLAttributes<HTMLElement>, any> | FunctionComponent<HTMLAttributes<HTMLElement>> | undefined'. TS2322
8 | }
9 | export default ({ text, date }: Props) => (
> 10 | <Typography component="p" gutterBottom>
| ^
11 | {text && <span>{text}: </span>}
12 | <FormattedDate value={date} />
13 |
Вот как выглядит мой компонент
import React from 'react';
import { FormattedDate, FormattedTime } from 'react-intl';
import Typography from '@material-ui/core/Typography';
interface Props {
date: Date;
text?: string;
}
export default ({ text, date }: Props) => (
<Typography component="p" gutterBottom>
{text && <span>{text}: </span>}
<FormattedDate value={date} />
<FormattedTime value={date} />
</Typography>
);
Яне в состоянии понять, почему "p"
не является приемлемым значением для component
проп. Я попробовал это с "h1"
и "h2"
, которые не работают таким же образом, и, очевидно, официальная демоверсия также использует строку.
Есть ли что-то, что мне не хватает ?, яне хочу игнорировать это с помощью // @ts-ignore
, но хочу это исправить.