Skip to content

Commit 9170e43

Browse files
authored
Improve reducer warning (#207)
* Fix formatting * Improve missing reducer error message
1 parent 0b8f279 commit 9170e43

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

docs/api/createAction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ console.log(`The action type is: ${increment}`)
4949
5050
## Using Prepare Callbacks to Customize Action Contents
5151
52-
By default, the generated action creators accept a single argument, which becomes `action.payload`. This requires the caller to construct the entire payload correctly and pass it in.
52+
By default, the generated action creators accept a single argument, which becomes `action.payload`. This requires the caller to construct the entire payload correctly and pass it in.
5353
54-
In many cases, you may want to write additional logic to customize the creation of the `payload` value, such as accepting multiple parameters for the action creator, generating a random ID, or getting the current timestamp. To do this, `createAction` accepts an optional second argument: a "prepare callback" that will be used to construct the payload value.
54+
In many cases, you may want to write additional logic to customize the creation of the `payload` value, such as accepting multiple parameters for the action creator, generating a random ID, or getting the current timestamp. To do this, `createAction` accepts an optional second argument: a "prepare callback" that will be used to construct the payload value.
5555
5656
```js
5757
import v4 from 'uuid/v4'

src/configureStore.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('configureStore', () => {
5050
describe('given no reducer', () => {
5151
it('throws', () => {
5252
expect(configureStore).toThrow(
53-
'Reducer argument must be a function or an object of functions that can be passed to combineReducers'
53+
'"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers'
5454
)
5555
})
5656
})

src/configureStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export function configureStore<S = any, A extends Action = AnyAction>(
109109
rootReducer = combineReducers(reducer)
110110
} else {
111111
throw new Error(
112-
'Reducer argument must be a function or an object of functions that can be passed to combineReducers'
112+
'"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers'
113113
)
114114
}
115115

type-tests/files/createSlice.typetest.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,29 +170,27 @@ function expectType<T>(t: T) {
170170
})
171171
}
172172

173-
174173
/*
175174
* Test: if no Payload Type is specified, accept any payload
176175
* see https://github.com/reduxjs/redux-starter-kit/issues/165
177176
*/
178177
{
179178
const initialState = {
180179
name: null
181-
};
182-
180+
}
183181

184182
const mySlice = createSlice({
185183
initialState,
186184
reducers: {
187185
setName: (state, action) => {
188-
state.name = action.payload;
186+
state.name = action.payload
189187
}
190188
}
191-
});
189+
})
192190

193-
const x = mySlice.actions.setName;
191+
const x = mySlice.actions.setName
194192

195-
mySlice.actions.setName(null);
196-
mySlice.actions.setName("asd");
197-
mySlice.actions.setName(5);
198-
}
193+
mySlice.actions.setName(null)
194+
mySlice.actions.setName('asd')
195+
mySlice.actions.setName(5)
196+
}

0 commit comments

Comments
 (0)