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.

Always loading initialState

See original GitHub issue

Great package! When I tried this, it seems that it always loads the initial state for me. My code looks like this:

import { AsyncStorage } from 'react-native'
import { applyMiddleware, createStore, compose } from 'redux'
import { persistStore, autoRehydrate } from 'redux-persist'
import createLogger from 'redux-logger'

import reducersCombined from './reducers/combined'
import initialState from './initialState'

const middlewares = [
  createLogger()
]

const enhancers = [
  applyMiddleware(...middlewares),
  autoRehydrate()
]

const store = createStore(reducersCombined, initialState, compose(...enhancers))
persistStore(store, { storage: AsyncStorage })

export default store

What am I doing wrong here? Could be that I misunderstood something as I’m quite new to redux.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:26
  • Comments:53 (4 by maintainers)

github_iconTop GitHub Comments

31reactions
mbifulcocommented, Dec 9, 2016

Shoot. persistStore happens after return? Good idea, self.

26reactions
OlegPanfyorovcommented, Feb 18, 2019

@leguma Thanks, yep the problem was in my reducer. My mistake was in “default: return { … state }” not “return state”

Read more comments on GitHub >

github_iconTop Results From Across the Web

default state of loading in reducer always true? - Stack Overflow
Above problem is that SomethingElse component will still got rendered once which is not what I want. So what's your initialState of loading?...
Read more >
Initializing State | Redux
In general, preloadedState wins over the state specified by the reducer. This lets reducers specify initial data that makes sense to them as ......
Read more >
HOW TO PROPERLY SET INITIAL STATE IN REDUX
There is only one way to change its state and that is by dispatching actions. Actions are objects that consist of a type...
Read more >
Why do I receive an error loading initial state when building a ...
Why do I receive an error loading initial state. ... Error loading the initial state for model 'Subsystem'. ... More often than not....
Read more >
State persistence | React Navigation
initialState - This prop allows us to pass an initial state to use for navigation ... an empty/loading view for a moment before...
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