-
Notifications
You must be signed in to change notification settings - Fork 14
feat(ui,Typography): Исправлена ошибка с передачей prop component #202
Conversation
packages/ui/src/Typography/types.ts
Outdated
import { TypographyProps as MuiTypographyProps } from '@mui/material/Typography'; | ||
import { Variant } from '@mui/material/styles/createTypography'; | ||
|
||
export type OverrideComponentProps<P, C extends React.ElementType> = P & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Объясни пжлст что это и зачем?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Насколько я понимаю это способ добавить какой-то кастомный variant
?! Если так, то разрабы материала предусмотрели такую ситуацию и позволяют делать это намного проще через TypographyPropsVariantOverrides
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тут очень сложно будет текстом расписать, но смысл какой, есть вот такое issue mui/material-ui#13921, когда мы в Typography добавляем prop component, TS не видит его, хотя он есть и я решил, что для решения текущей проблемы необходимо сделать OverrideComponent и этой конструкцией я переопределяю все пропсы.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
И это сделано было для того, что бы была возможность добавлять дополнительные пропсы и TS не ругался бы. К примеру мы в Typography положили img, () и ему нужен alt без текущих манипуляций TS ругался бы
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это не для variant, а для component было сделано
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Он же может быть и не span?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
span это дефолтный компонент передается, так в material ui реализовано
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variant, | ||
children, | ||
...props | ||
}: TypographyProps) => { | ||
}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не хватает forwardRef
No description provided.