Skip to content

Commit 99f357d

Browse files
committed
Update createSlice docs to remove selector references
1 parent 2a43dff commit 99f357d

File tree

1 file changed

+4
-20
lines changed

1 file changed

+4
-20
lines changed

docs/api/createSlice.md

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ hide_title: true
77

88
# `createSlice`
99

10-
A function that accepts an initial state, an object full of reducer functions, and optionally a "slice name", and automatically generates action creators, action types, and selectors that correspond to the reducers and state.
10+
A function that accepts an initial state, an object full of reducer functions, and optionally a "slice name",
11+
and automatically generates action creators and action types that correspond to the reducers and state.
1112

1213
## Parameters
1314

@@ -19,7 +20,7 @@ function createSlice({
1920
reducers: Object<string, ReducerFunction>
2021
// The initial state for the reducer
2122
initialState: any,
22-
// An optional name, used in action types and selectors
23+
// An optional name, used in action types
2324
slice?: string,
2425
// An additional object of "case reducers". Keys should be other action types.
2526
extraReducers?: Object<string, ReducerFunction>
@@ -45,16 +46,7 @@ The initial state value for this slice of state.
4546

4647
### `slice`
4748

48-
An optional string name for this slice of state.
49-
50-
The slice name is used in two ways.
51-
52-
First, if provided, generated action type constants will use this as a prefix.
53-
54-
Second, it affects the name and behavior of the generated selector. If provided, a selector named after the slice
55-
will be generated. This selector assume the slice data exists in an object, with the slice name as the key, and will
56-
return the value at that key name. If not provided, a selector named `getState` will be generated that just returns
57-
its argument.
49+
An optional string name for this slice of state. Generated action type constants will use this as a prefix.
5850

5951
### `extraReducers`
6052

@@ -84,7 +76,6 @@ to force the TS compiler to accept the computed property.)
8476
slice : string,
8577
reducer : ReducerFunction,
8678
actions : Object<string, ActionCreator},
87-
selectors : Object<string, Selector>
8879
}
8980
```
9081

@@ -93,8 +84,6 @@ and included in the result's `actions` field using the same function name.
9384

9485
The generated `reducer` function is suitable for passing to the Redux `combineReducers` function as a "slice reducer".
9586

96-
The generated selector function will be available in the result's `selectors` field.
97-
9887
You may want to consider destructuring the action creators and exporting them individually, for ease of searching
9988
for references in a larger codebase.
10089

@@ -156,9 +145,4 @@ console.log(`${counter.actions.decrement}`)
156145
// -> "counter/decrement"
157146
store.dispatch(user.actions.setUserName('eric'))
158147
// -> { counter: 6, user: { name: 'eric', age: 22} }
159-
const state = store.getState()
160-
console.log(user.selectors.getUser(state))
161-
// -> { name: 'eric', age: 22 }
162-
console.log(counter.selectors.getCounter(state))
163-
// -> 6
164148
```

0 commit comments

Comments
 (0)