question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reducer is initialized by default parameters before sync with local storage

See original GitHub issue

Hi guys, when I configure stores app is rendered with initialState after that data will be sync and re-rendered with data from localStorage. Can I initialize store immediately with localStorate instead?


const configureStore = function configureStore(initialState) {
  const store = createStore(reducer, initialState, compose(
    autoRehydrate(),
    applyMiddleware(thunk),
    window.devToolsExtension ? window.devToolsExtension() : f => f
  ));

  if (module.hot) {
    // Enable Webpack hot module replacement for reducers
    module.hot.accept('../reducers', () => {
      const nextReducer = require('../reducers');
      store.replaceReducer(nextReducer);
    });
  }

  return store;
};

const store = configureStore({applications, candidates, settings, vacancies});
persistStore(store);

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
fforrescommented, Jul 18, 2016

@vdzundza @gausie Did you guys manage to implement it? I’m a little bit lost on how the asyncronous injection of reducers handles the stores

3reactions
Kinjeirocommented, Nov 16, 2016

For example, there is recipe “Delay Render Until Rehydration Complete” https://github.com/rt2zz/redux-persist/blob/master/docs/recipes.md#delay-render-until-rehydration-complete

Read more comments on GitHub >

github_iconTop Results From Across the Web

Where to write to localStorage in a Redux app? - Stack Overflow
If you use combineReducers() you'll notice that reducers that haven't received the state will “boot up” as normal using their default state argument...
Read more >
Redux: Persisting the State to the Local Storage - Egghead.io
We will learn how to use store.subscribe() to efficiently persist some of the app's state to localStorage and restore it after a refresh....
Read more >
Initializing State | Redux
All reducers are passed undefined on initialization, so they should be written such that when given undefined , some value should be returned....
Read more >
How to persist Redux state in local Storage without any ...
Filename: reducer.js This file contains the reducer function. As per the action dispatched through the UI, the corresponding functionality takes ...
Read more >
Persisting Redux State to Local Storage | by Jam Creencia
}); });. The saveState function is called inside the store.subscribe listener so it is called every time the storage state changes ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found