I have trouble accessing the length of an undefined array here is a snippet of my code:
const pages = []
for(let i = 1; i <= Math.ceil(users.length / itemsPerPage);i++){
pages.push(i);
}
我认为当您获取数据时,您将您的状态覆盖为{isLoaded: true, users: result.users}
并删除其他所有内容,而是使用扩展运算符,因此您未更新的属性会保留,例如{...this.state, isLoaded: true}
,这样你就可以保留其他所有内容。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.