属性 'item' 在类型 'IntrinsicAttributes & RefAttributes<Component<{}, any, any>>' 上不存在 'IntrinsicAttributes & RefAttributes<Component<{}, any, any>>'.ts(2322)
Property 'item' does not exist on type 'IntrinsicAttributes & RefAttributes<Component<{}, any, any>>'.ts(2322)
"反应": "^16.12.0",
“打字稿”:“^4.0.3”,
“下一个”:“^9.4.4”
因此打字稿在子组件中定义的项目属性 <Item item={item} key={item.id} urlReferer={urlReferer} />
上发出上述错误。我该如何解决?
ItemListItems.tsx
Item.tsx
已解决:Apollo HOC 要求指定 InputProps 以反映组件中正在使用的道具:
component/Item.tsx
type InputProps = {
item: Item;
urlReferer: string;
};
type ChildProps = ChildDataProps<InputProps, Response, {}>
const userQuery = graphql<InputProps, Response, {}, ChildProps>(
CURRENT_USER_QUERY,
{
options: {
fetchPolicy: 'cache-and-network',
pollInterval: 300
},
}
);
interface Props {
data?: any;
item?: Item;
urlReferer?: string;
}
const ItemComp: FC<Props> = ({ item, urlReferer, data: { me, error, stopPolling, subscribeToMore }}) => {
"反应": "^16.12.0",
“打字稿”:“^4.0.3”,
“下一个”:“^9.4.4”
因此打字稿在子组件中定义的项目属性 <Item item={item} key={item.id} urlReferer={urlReferer} />
上发出上述错误。我该如何解决?
ItemListItems.tsx
Item.tsx
已解决:Apollo HOC 要求指定 InputProps 以反映组件中正在使用的道具:
component/Item.tsx
type InputProps = {
item: Item;
urlReferer: string;
};
type ChildProps = ChildDataProps<InputProps, Response, {}>
const userQuery = graphql<InputProps, Response, {}, ChildProps>(
CURRENT_USER_QUERY,
{
options: {
fetchPolicy: 'cache-and-network',
pollInterval: 300
},
}
);
interface Props {
data?: any;
item?: Item;
urlReferer?: string;
}
const ItemComp: FC<Props> = ({ item, urlReferer, data: { me, error, stopPolling, subscribeToMore }}) => {