我应该将搜索结果存储在 redux store 中吗? [英] Should I store search result in redux store?

查看:38
本文介绍了我应该将搜索结果存储在 redux store 中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

搜索结果通常是暂时的.

Search result in general is temporary in nature.

我认为将搜索结果存储在商店中没有多大意义.

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

在这种情况下,我应该使用 react 的 setState 来呈现搜索结果吗?

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

推荐答案

视情况而定,一种将搜索结果存储在商店中的用例是:

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

  1. 用户转到/search 并搜索很棒的廉价汽车"
  2. 用户点击结果列表中出现的第三辆车
  3. 用户不喜欢这辆车,并在浏览器中按下后退按钮

现在,如果您将搜索查询和搜索结果存储在商店中,您可以使用相同的结果重新呈现搜索页面,而无需再次往返服务器,它看起来就像是即时加载给用户一样.

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.

我会亲自将结果存储在 store.search 中

I would personally store the results in store.search

这篇关于我应该将搜索结果存储在 redux store 中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆