Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bindActionCreators.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default function bindActionCreators(actionCreators, dispatch) {

var keys = Object.keys(actionCreators)
var boundActionCreators = {}
for (var i = 0; i < keys.length; i++) {
for (let i = 0; i < keys.length; i++) {
var key = keys[i]
var actionCreator = actionCreators[key]
if (typeof actionCreator === 'function') {
Expand Down
10 changes: 5 additions & 5 deletions src/combineReducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import warning from './utils/warning'

function getUndefinedStateErrorMessage(key, action) {
var actionType = action && action.type
var actionName = actionType && `"${actionType.toString()}"` || 'an action'
const actionName = actionType && `"${actionType.toString()}"` || 'an action'

return (
`Given action ${actionName}, reducer "${key}" returned undefined. ` +
Expand All @@ -14,7 +14,7 @@ function getUndefinedStateErrorMessage(key, action) {

function getUnexpectedStateShapeWarningMessage(inputState, reducers, action) {
var reducerKeys = Object.keys(reducers)
var argumentName = action && action.type === ActionTypes.INIT ?
const argumentName = action && action.type === ActionTypes.INIT ?
'initialState argument passed to createStore' :
'previous state received by the reducer'

Expand Down Expand Up @@ -93,7 +93,7 @@ function assertReducerSanity(reducers) {
export default function combineReducers(reducers) {
var reducerKeys = Object.keys(reducers)
var finalReducers = {}
for (var i = 0; i < reducerKeys.length; i++) {
for (let i = 0; i < reducerKeys.length; i++) {
var key = reducerKeys[i]
if (typeof reducers[key] === 'function') {
finalReducers[key] = reducers[key]
Expand All @@ -114,15 +114,15 @@ export default function combineReducers(reducers) {
}

if (process.env.NODE_ENV !== 'production') {
var warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action)
const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action)
if (warningMessage) {
warning(warningMessage)
}
}

var hasChanged = false
var nextState = {}
for (var i = 0; i < finalReducerKeys.length; i++) {
for (let i = 0; i < finalReducerKeys.length; i++) {
var key = finalReducerKeys[i]
var reducer = finalReducers[key]
var previousStateForKey = state[key]
Expand Down
7 changes: 5 additions & 2 deletions src/createStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export default function createStore(reducer, initialState, enhancer) {
function getState() {
return currentState
}


if (typeof getState !== 'function' || getState == 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getState is a locally defined function. It is guaranteed to be a function by the code unless I’m missing something.

throw new Error('Expected getState to be a function.')
}
/**
* Adds a change listener. It will be called any time an action is dispatched,
* and some part of the state tree may potentially have changed. You may then
Expand Down Expand Up @@ -172,7 +175,7 @@ export default function createStore(reducer, initialState, enhancer) {
}

var listeners = currentListeners = nextListeners
for (var i = 0; i < listeners.length; i++) {
for (let i = 0; i < listeners.length; i++) {
listeners[i]()
}

Expand Down