Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I store search result in redux store?

Tags:

reactjs

redux

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?

like image 858
eugene Avatar asked Oct 18 '16 10:10

eugene


1 Answers

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

like image 85
Borjante Avatar answered Oct 03 '22 08:10

Borjante