redux-persist with react-redux-starter-kit

Recently I’ve worked with react-redux-starter-kit and I needed to add redux-persist to save data between switching routes (walking through the webpage). Scenario was simple, load data from API – save it and on returning again to the page – load data from redux-store without calling an API – but on refreshing the page – call API to get new data.

In file src/store/createStore.js

Next in file src/main.jsadd

than in any file (i.e. src/routes/Menu/modules/menu.js, where you want to use redux-persist you can use:

in src/routes/Menu/containers/Menu.js

and probably that’s how to configure redux-persist with react-redux-starer-kit – the most important thing is with main.js and createStore.js files – where you binding redux-persist with redux.

Cheers

Rafath Khan

Rafath Khan - Problem Solver - nie ma czegoś takiego jak problem, są wyzwania. Od 1998 związany z Internetem, programista, projektant, twórca serwisów i aplikacji internetowych m.in Shoople.pl, PanShop.pl, UnikalneOpisy.pl. Masz problem? Pomogę CI go rozwiązać.

Może Ci się również spodoba