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.

Usage with createStore preloadedState parameter?

See original GitHub issue

Hi, I have the following code in my app.js reducer:

const defaultState = {
  count: 1,
  type: null,
}

...

export default handleActions(reducerMap, defaultState)

And I am trying to preload the type state when creating the store:

const preloadedState = {
  app: {
    type: "apple",
  },
}
const store = createStore(reducers, preloadedState, applyMiddleware(thunkMiddleware))

But I got the error that count state became undefined, Seems by using redux-actions I was unable to check and assign state into defaultState

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

6reactions
yangmillstheorycommented, Dec 11, 2016

shipit

0reactions
nodegincommented, Dec 11, 2016

@yangmillstheory I see, thanks for helping!

Read more comments on GitHub >

github_iconTop Results From Across the Web

createStore | Redux
createStore (reducer, [preloadedState], [enhancer]). Creates a Redux store that holds the complete state tree of your app.
Read more >
Unexpected key found in preloadedState argument passed to ...
TLDR: stop using combineReducers and pass your reducer to createStore directly. Use import reducer from './foo' instead of import * from './foo' ....
Read more >
createStore · Redux
Arguments · reducer (Function): A reducing function that returns the next state tree, given the current state tree and an action to handle....
Read more >
Second argument to createStore in redux - JavaScript
What i don't understand is the explanation of the second argument preloadedState . [ preloadedState ] (any) : The initial state. You may ......
Read more >
Initializing State - reducers - Redux Documents
The createStore method can accept an optional preloadedState value as its ... argument that is undefined , and returning the value they'd like...
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