Skip to content

Commit f9a5636

Browse files
authored
Fix Redux exports (#243)
* Export all types and methods from Redux * Update "Other Exports" and "createSlice" docs
1 parent b868b43 commit f9a5636

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

docs/api/createSlice.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ and automatically generates action creators and action types that correspond to
1717
```ts
1818
function createSlice({
1919
// An object of "case reducers". Key names will be used to generate actions.
20-
reducers: Object<string, ReducerFunction>
20+
reducers: Object<string, ReducerFunction | ReducerAndPrepareObject>
2121
// The initial state for the reducer
2222
initialState: any,
2323
// A name, used in action types
@@ -40,6 +40,10 @@ descriptive names.
4040
This object will be passed to [`createReducer`](./createReducer.md), so the reducers may safely "mutate" the
4141
state they are given.
4242

43+
#### Customizing Generated Action Creators
44+
45+
If you need to customize the creation of the payload value of an action creator by means of a [`prepare callback`](./createAction.md#using-prepare-callbacks-to-customize-action-contents), the value of the appropriate field of the `reducers` argument object should be an object instead of a function. This object must contain two properties: `reducer` and `prepare`. The value of the `reducer` field should be the case reducer function while the value of the `prepare` field should be the prepare callback function.
46+
4347
### `initialState`
4448

4549
The initial state value for this slice of state.
@@ -82,8 +86,6 @@ to force the TS compiler to accept the computed property.)
8286
Each function defined in the `reducers` argument will have a corresponding action creator generated using [`createAction`](./createAction.md)
8387
and included in the result's `actions` field using the same function name.
8488

85-
If you need to customize the creation of the payload value of an action creator by means of a [`prepare callback`](./createAction.md#using-prepare-callbacks-to-customize-action-contents), the value of the appropriate field of the `reducers` argument object should be an object instead of a function. This object must contain two properties: reducer and prepare. The value of the reducer field should be the case reducer function while the value of the prepare field should be the prepare callback function.
86-
8789
The generated `reducer` function is suitable for passing to the Redux `combineReducers` function as a "slice reducer".
8890

8991
You may want to consider destructuring the action creators and exporting them individually, for ease of searching

docs/api/otherExports.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,25 @@ function isPlain(val) {
6868

6969
### `createNextState`
7070

71-
The default immutable update function from the [`immer` library](https://github.com/mweststrate/immer#api), re-exported here as `createNextState` (also commonly referred to as `produce`)
71+
The default immutable update function from the [`immer` library](https://immerjs.github.io/immer/), re-exported here as `createNextState` (also commonly referred to as [`produce`](https://immerjs.github.io/immer/docs/produce))
7272

7373
### `combineReducers`
7474

75-
Redux's `combineReducers`, re-exported for convenience. While `configureStore` calls this internally, you may wish to call it yourself to compose multiple levels of slice reducers.
75+
Redux's [`combineReducers`](https://redux.js.org/api/combinereducers), re-exported for convenience. While `configureStore` calls this internally, you may wish to call it yourself to compose multiple levels of slice reducers.
7676

7777
### `compose`
7878

79-
Redux's `compose`. It composes functions from right to left.
79+
Redux's [`compose`](https://redux.js.org/api/compose). It composes functions from right to left.
8080
This is a functional programming utility. You might want to use it to apply several store custom enhancers/ functions in a row.
81+
82+
### `bindActionCreators`
83+
84+
Redux's [`bindActionCreators`](https://redux.js.org/api/bindactioncreators). It wraps action creators with `dispatch()` so that they dispatch immediately when called.
85+
86+
### `createStore`
87+
88+
Redux's [`createStore`](https://redux.js.org/api/createstore). You should not need to use this directly.
89+
90+
### `applyMiddleware`
91+
92+
Redux's [`applyMiddleware`](https://redux.js.org/api/applymiddleware). You should not need to use this directly.

src/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
export {
2-
Action,
3-
ActionCreator,
4-
AnyAction,
5-
Middleware,
6-
Reducer,
7-
Store,
8-
StoreEnhancer,
9-
combineReducers,
10-
compose
11-
} from 'redux'
1+
export * from 'redux'
122
export { default as createNextState } from 'immer'
133
export { createSelector } from 'reselect'
144

0 commit comments

Comments
 (0)