What is the initialState used for in Redux createStore function

Viewed 4112

All:

When I read the source of Redux, in its createStore:

function createStore(reducer, initialState, enhancer) {
    ......
    var currentState = initialState;
    ......
    dispatch({ type: ActionTypes.INIT });
    ......
}

When create a new store, it sets currentState to initialState, and call reducer in init dispatch to update the default state value. I wonder: generally the currentStatew will be given a value from reducer, then what is the purpose of that initialState?

Thanks

1 Answers
Related