我注意到了react admin字段组件道具类型中的这种类型模式:
export interface MyCustomFieldProps
extends PublicFieldProps,
InjectedFieldProps,
TypographyProps {
[myCustomFieldExtraProp: string]: any
}但有时TypographyProps没有扩展。我不知道为什么。我认为字段组件道具类型应该只在返回字体组件时扩展TypographyProps。
下面是一些例子:
DateField
export interface DateFieldProps
extends PublicFieldProps,
InjectedFieldProps,
TypographyProps {
locales?: string | string[];
options?: object;
showTime?: boolean;
}FileField
export interface FileFieldProps extends PublicFieldProps, InjectedFieldProps {
src?: string;
title?: string;
target?: string;
download?: boolean | string;
ping?: string;
rel?: string;
classes?: object;
}但是,我发现了一些字段组件,它们返回一个排版,但不扩展TypographyProps。因此使我的思想失效。
就像这个:
EmailField
export interface EmailFieldProps
extends PublicFieldProps,
InjectedFieldProps,
AnchorHTMLAttributes<HTMLAnchorElement> {}发布于 2022-05-03 18:23:51
我花了些时间做进一步调查。看起来,只有返回排版组件的字段才是扩展TypographyProps的字段。
返回值和emptyText.
可能返回另一个组件而不是排版的字段不会扩展TypographyProps:
的排版
我想它是以这种方式实现的,所以当我们将Typograph道具传递给字段组件时,我们不会感到困惑,因为字段组件需要在值组件中进行更改(而不是排版)。因为它只应用于emptyText组件(排版)。
https://stackoverflow.com/questions/72092570
复制相似问题