如何在 React Hook 中使用 useState 更新整个 Uint8Array 值?
How to update whole Uint8Array value using useState in React Hook?
const [dummy, setDummy] = useState([])
//Assume pdfByte is of Uint8Array(403970)
setDummy(prevState => [...prevState, pdfByte])
我尝试用这种方式更新它,但它不起作用。我想将整个数组更改为新值。有什么办法吗?下面是新值(Uint8Array)的样子。
由于您不想使用以前的值,您可以简单地将更新后的值传递给 setDummy
setDummy(pdfByte)
const [dummy, setDummy] = useState([])
//Assume pdfByte is of Uint8Array(403970)
setDummy(prevState => [...prevState, pdfByte])
我尝试用这种方式更新它,但它不起作用。我想将整个数组更改为新值。有什么办法吗?下面是新值(Uint8Array)的样子。
由于您不想使用以前的值,您可以简单地将更新后的值传递给 setDummy
setDummy(pdfByte)