You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"0": "It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.",
3
-
"1": "Expected the enhancer to be a function.",
4
-
"2": "Expected the reducer to be a function.",
2
+
"0": "It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.",
3
+
"1": "Expected the enhancer to be a function. Instead, received: ''",
4
+
"2": "Expected the root reducer to be a function. Instead, received: ''",
5
5
"3": "You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.",
6
-
"4": "Expected the listener to be a function.",
6
+
"4": "Expected the listener to be a function. Instead, received: ''",
7
7
"5": "You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.",
8
8
"6": "You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.",
9
-
"7": "Actions must be plain objects. Use custom middleware for async actions.",
10
-
"8": "Actions may not have an undefined \"type\" property. Have you misspelled a constant?",
9
+
"7": "Actions must be plain objects. Instead, the actual type was: ''. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.",
10
+
"8": "Actions may not have an undefined \"type\" property. You may have misspelled an action type string constant.",
11
11
"9": "Reducers may not dispatch actions.",
12
-
"10": "Expected the nextReducer to be a function.",
13
-
"11": "Expected the observer to be an object.",
14
-
"12": "bindActionCreators expected an object or a function, instead received . Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?",
15
-
"13": "Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.",
16
-
"14": "Reducer \"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.",
17
-
"15": "Reducer \"\" returned undefined when probed with a random type. Don't try to handle or other actions in \"redux/*\" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.",
18
-
"16": "Super expression must either be null or a function"
12
+
"10": "Expected the nextReducer to be a function. Instead, received: '",
13
+
"11": "Expected the observer to be an object. Instead, received: ''",
14
+
"12": "The slice reducer for key \"\" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.",
15
+
"13": "The slice reducer for key \"\" returned undefined when probed with a random type. Don't try to handle '' or other actions in \"redux/*\" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.",
16
+
"14": "When called with an action of type , the slice reducer for key \"\" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.",
17
+
"15": "Dispatching while constructing your middleware is not allowed. Other middleware would not be applied to this dispatch.",
18
+
"16": "bindActionCreators expected an object or a function, but instead received: ''. Did you write \"import ActionCreators from\" instead of \"import * as ActionCreators from\"?"
Copy file name to clipboardExpand all lines: src/createStore.ts
+31-10
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ import { Action } from './types/actions'
12
12
import{Reducer}from'./types/reducers'
13
13
importActionTypesfrom'./utils/actionTypes'
14
14
importisPlainObjectfrom'./utils/isPlainObject'
15
+
import{kindOf}from'./utils/kindOf'
15
16
16
17
/**
17
18
* Creates a Redux store that holds the state tree.
@@ -74,7 +75,7 @@ export default function createStore<
74
75
thrownewError(
75
76
'It looks like you are passing several store enhancers to '+
76
77
'createStore(). This is not supported. Instead, compose them '+
77
-
'together to a single function.'
78
+
'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.'
78
79
)
79
80
}
80
81
@@ -85,7 +86,11 @@ export default function createStore<
85
86
86
87
if(typeofenhancer!=='undefined'){
87
88
if(typeofenhancer!=='function'){
88
-
thrownewError('Expected the enhancer to be a function.')
89
+
thrownewError(
90
+
`Expected the enhancer to be a function. Instead, received: '${kindOf(
91
+
enhancer
92
+
)}'`
93
+
)
89
94
}
90
95
91
96
returnenhancer(createStore)(
@@ -95,7 +100,11 @@ export default function createStore<
95
100
}
96
101
97
102
if(typeofreducer!=='function'){
98
-
thrownewError('Expected the reducer to be a function.')
103
+
thrownewError(
104
+
`Expected the root reducer to be a function. Instead, received: '${kindOf(
105
+
reducer
106
+
)}'`
107
+
)
99
108
}
100
109
101
110
letcurrentReducer=reducer
@@ -159,7 +168,11 @@ export default function createStore<
159
168
*/
160
169
functionsubscribe(listener: ()=>void){
161
170
if(typeoflistener!=='function'){
162
-
thrownewError('Expected the listener to be a function.')
171
+
thrownewError(
172
+
`Expected the listener to be a function. Instead, received: '${kindOf(
173
+
listener
174
+
)}'`
175
+
)
163
176
}
164
177
165
178
if(isDispatching){
@@ -225,15 +238,15 @@ export default function createStore<
225
238
functiondispatch(action: A){
226
239
if(!isPlainObject(action)){
227
240
thrownewError(
228
-
'Actions must be plain objects. '+
229
-
'Use custom middleware for async actions.'
241
+
`Actions must be plain objects. Instead, the actual type was: '${kindOf(
242
+
action
243
+
)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`
230
244
)
231
245
}
232
246
233
247
if(typeofaction.type==='undefined'){
234
248
thrownewError(
235
-
'Actions may not have an undefined "type" property. '+
236
-
'Have you misspelled a constant?'
249
+
'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.'
237
250
)
238
251
}
239
252
@@ -271,7 +284,11 @@ export default function createStore<
0 commit comments