如何使可选数字 useState 变量?

时间:2021-08-01 21:22:23

标签: reactjs typescript

这就是我声明和初始化 imageCount 的方式,但是出了点问题:

const [imageCount, setImageCount]: number | undefined = undefined;

我收到此错误:

TypeError: Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.

0 个答案:

没有答案