Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教一下楼主ajax请求返回的数据合并问题 #1

Closed
zwl1619 opened this issue Nov 25, 2018 · 4 comments
Closed

请教一下楼主ajax请求返回的数据合并问题 #1

zwl1619 opened this issue Nov 25, 2018 · 4 comments

Comments

@zwl1619
Copy link

zwl1619 commented Nov 25, 2018

请教一下楼主,src/components/articles/articles.js文件第125行,如下图所示:

image

每次下拉触发ajax请求,取回了一定数量的的数据,每取回一次都要和已经取回的数据进行一次合并操作,当一直往下拉的时候,数据会越来越多,数组越来越大,会不会性能很差呢?

@biaochenxuying
Copy link
Owner

请教一下楼主,src/components/articles/articles.js文件第125行,如下图所示:

image

每次下拉触发ajax请求,取回了一定数量的的数据,每取回一次都要和已经取回的数据进行一次合并操作,当一直往下拉的时候,数据会越来越多,数组越来越大,会不会性能很差呢?

性能会变差的,小数据能这么做,当然有很大数据时最好就不要了,用扩展运算符 ... 会好点。

@1ess
Copy link

1ess commented Nov 27, 2018

这里的 setState 用 prevState 好点吧

@1ess
Copy link

1ess commented Nov 27, 2018

6ffb120239dc3d4c4f78f2998a9cafc
我没用官方 demo 的写法,这么写我感觉不错。code标签就不用你自己写样式了

@biaochenxuying
Copy link
Owner

查了一下,是 prevState 好;marked 的用法好多的,好用就好。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants