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

關於placeholder in react #14

Open
AngeloETH opened this issue Sep 23, 2018 · 1 comment
Open

關於placeholder in react #14

AngeloETH opened this issue Sep 23, 2018 · 1 comment

Comments

@AngeloETH
Copy link

Huli大您好,我之前有上過您的前端新手加強班並動手實作作業1作業9,目前自行將作業10的內容branch成用react改寫整個作業1作業9 XD,這邊想請教一個placeholder的問題: 在react中,可否直接將placeholder的資料包成物件在constructor時放在state的一個array中({frame: Array(limit).fill(placeholder)},然後placeholder是個物件放那些暫位圖及文字這樣),然後在componentDidMount()時發送request拿twitch api,當拿到api後直接setState將state的frame改成api的資料,如此也能達到placeholder的效果,不知道在實務上這樣操作跟您該課程第五周教的placeholder方法會使用哪種呢? 優劣又是為何?

@aszx87410
Copy link
Member

你這樣做法還是有差喔
差別在於你 setState 之後,新的那些圖片依然還是需要時間載入,所以你還是會看到有一瞬間畫面是沒有任何圖片的,連佔位圖也沒有,因為你已經是新的 state 了

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

2 participants