Should I store search result in redux store?

reactjs, redux

Solution

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

- Users goes to /search and searches for "awesome cheap cars"

- User clicks on the third car that appears in the results list

- 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

Problem

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?

Original source