Should I store search result in redux store?

天涯浪子 提交于 2020-01-14 08:37:40

问题


Search result in general is temporary in nature.

I don't see much point storing the search result in the store.

Should I use react's setState to render the search results in this case?


回答1:


Depends, one use case for storing the search results in the store is:

  1. Users goes to /search and searches for "awesome cheap cars"
  2. User clicks on the third car that appears in the results list
  3. User does not like the car, and presses the back button in the browser

Now, if you stored the search query and the search result in the store, you can rerender the search page with the same results without another rountrip to the server and it will look like instant loading to the user.

I would personally store the results in store.search



来源:https://stackoverflow.com/questions/40105532/should-i-store-search-result-in-redux-store

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!