Skip to content

Handle initial state on store create #39

@desktoping

Description

@desktoping

how do we handle initial state as state passed down by store?

const initialState = {
  count: 1
}

export default (reducers) => (
  createStore(
    combineReducer(reducers),
    initialState,
    applyMiddleware(...)
  )
)

do we have access to the initial state on State?

export default State('count', {
  initial: {
    count: state.count || 1 // should be the same as the initialized value
  },
  addCount,
  subCount
})

EDIT
sorry it seems i went ahead not looking at the source.
https://github.com/jumpsuit/jumpstate/blob/master/src/state.js#L32
thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions