“反应”:“ ^ 16.12.0”,
“ typescript”:“ ^ 4.0.3”,
“ next”:“ ^ 9.4.4”
因此,打字稿正在道具prop <Item item={item} key={item.id} urlReferer={urlReferer} />
上发出上述错误,该错误在子组件中定义。我该如何解决?
ItemListItems.tsx
Item.tsx
答案 0 :(得分:1)
已解决: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 }}) => {