Skip to content

v0.4.1: `createSlice` and `extraReducers`

Compare
Choose a tag to compare
@markerikson markerikson released this 25 Jan 03:17
· 3450 commits to master since this release

createSlice generates action types directly from the names of the reducer functions you provide in the reducers field. However, this conceptually limits a slice's reducer to only responding to action types that it "owns" and defined.

We have always encouraged Redux users to have multiple reducer functions responding to the same action type. In order to support this, createSlice now accepts a second lookup table of action types, currently named extraReducers. (The name is not final - we're still debating options. If you've got a better name, please let us know in #83 .)

Unlike the reducers field, the extraReducers field will not generate action creators for the provided functions, and the keys should be other existing Redux action type constants.

In addition to the createSlice changes, the TS conversion process accidentally stopped re-exporting compose and combineReducers from Redux. That's been fixed.