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.

autoRehydrate doesn't working with hot reloading

See original GitHub issue

Thank you for this great library, I’m using it with RN for building an iOS app. I have noticed that if I apply the autoRehydrate() method in my configureStore.js that the hot reloading of iOS simulator won’t working, there’s any suggestion for this or if I can just remove the autoRehydrate(), if I do this will the redux-persist sill workable?

Here’s my configureStore.js :

/* @flow */

import { AsyncStorage } from 'react-native';
import { createStore, applyMiddleware } from 'redux';
import { composeWithDevTools } from 'remote-redux-devtools';
import thunk from 'redux-thunk';
import { persistStore, autoRehydrate } from 'redux-persist';
import rootReducer from '../reducers';

export default (onComplete?: () => void): any => {
  const store = createStore(rootReducer, composeWithDevTools(
    applyMiddleware(thunk),
    autoRehydrate(),
  ));

  if (module.hot) {
    // $FlowFixMe
    module.hot.accept(() => {
      const nextRootReducer = require('../reducers').default;
      store.replaceReducer(nextRootReducer);
    });
  }

  persistStore(store, { storage: AsyncStorage }, onComplete);

  return store;
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
zalmoxisuscommented, Feb 1, 2017

Not sure it is redux-devtools problem, but you can disable recomputing actions there by setting shouldHotReload to false:

const composeEnhancers = composeWithDevTools({ shouldHotReload: false });
  const store = createStore(rootReducer, composeEnhancers(
    applyMiddleware(thunk),
    autoRehydrate(),
  ));

See more details in the devtools API.

1reaction
rt2zzcommented, Feb 6, 2017

@wellyshen I am not sure, in the past I have not enabled hot reload for reducers, only component tree. That said it should work, but I think may be complicated by the abstraction level that was chosen for autoRehydrate (a store enhancer). In reality a higher order reducer is sufficient and simpler.

Towards that effect, I would recommend you give https://github.com/rt2zz/redux-persist-state-manager a try. It is a higher order reducer which plays the same role as autoRehydrate and will soon be the recommended solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[RN][Redux-Persist] AutoRehydrate is not a function
I am using redux-persist 5.5.0 When I debug my react native app, Error say "autoRehydrate is not a function" my source code here, ......
Read more >
Hot reload - Flutter documentation
Hot reload doesn't work when enumerated types are changed to regular classes or regular classes are changed to enumerated types. For example: Before...
Read more >
Write and debug code by using Hot Reload - Visual Studio ...
Hot Reload, similar to edit and continue, allows you to make changes to your code while running apps.
Read more >
дэн on Twitter: "Frustrated by broken hot reloading in React ...
Six months ago the community told us Hot Reloading was a major pain ... Hot Reloading is not working · Issue #18899 ·...
Read more >
Introducing Hot Reloading - React Native
Hot Reloading should work out of the box for the most common use cases. HMR Runtime​. As we've seen before, sometimes it's not...
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