Created
July 23, 2017 09:28
-
-
Save oxidist/1a0296017a95a191e8184fa7d85193a1 to your computer and use it in GitHub Desktop.
test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ActionTypes } from '../createStore'; | |
import isPlainObject from '../utils/isPlainObject'; | |
import mapValues from '../utils/mapValues'; | |
import pick from '../utils/pick'; | |
/* eslint-disable no-console quotes no-unused-vars */ | |
function getErrorMessage(key, action) { | |
var actionType = action && action.type; | |
var actionName = actionType && ('"${actionType.toString()}"') || ('an action'); | |
return ( | |
`Reducer "${key}" returned undefined handling ${actionName}. ` + | |
`To ignore an action, you must explicitly return the previous state.` | |
); | |
} | |
function verifyStateShape(initialState, currentState) { | |
var reducerKeys = Object.keys(currentState); | |
if (reducerKeys.length === 0) { | |
console.error( | |
'Store does not have a valid reducer. Make sure the argument passed ' + | |
'to combineReducers is an object whose values are reducers.' | |
); | |
return; | |
} | |
if (!isPlainObject(initialState)) { | |
console.error( | |
'initialState has unexpected type of "' + | |
({}).toString.call(initialState).match(/\s([a-z|A-Z]+)/)[1] + | |
'". Expected initialState to be an object with the following ' + | |
`keys: "${reducerKeys.join('", "')}"` | |
); | |
return; | |
} | |
var unexpectedKeys = Object.keys(initialState).filter( | |
key => reducerKeys.indexOf(key) < 0 | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment