首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >为什么钩子的初始值不能为空对象?

为什么钩子的初始值不能为空对象?
EN

Stack Overflow用户
提问于 2019-06-10 07:31:03
回答 1查看 6K关注 0票数 4

我有这个setProd Hooks

代码语言:javascript
复制
export interface faceProduct {
  readonly title: string;
  readonly prodState: string;
  readonly shipping: string;
  readonly sold: string;
  readonly alt: string;
  readonly material: string;
  readonly location: string;
  readonly src: string[];
  readonly color: string[];
  readonly saiz: string[];
  readonly price: string;
}

export interface faceProductList extends faceProduct {
  readonly id: string;
  readonly to: string;
}

 const [prod, setProd] = useState<faceProductList>({});

我希望初始值是空的object.but,我得到了错误。

代码语言:javascript
复制
 const [prod, setProd] = useState<faceProductList>(Object);

每件事都与它相关联的东西一起工作。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56519104

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档