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
Copy file name to clipboardExpand all lines: docs/api/createSelector.md
+8-40Lines changed: 8 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -7,46 +7,14 @@ hide_title: true
7
7
8
8
# `createSelector`
9
9
10
-
The `createSelector` utility from the [`selectorator` library](https://github.com/planttheidea/selectorator), re-exported for ease of use. It acts as a superset of the standard `createSelector` function from [Reselect](https://github.com/reactjs/reselect). The primary improvements are the ability to define "input selectors" using string keypaths, or return an object result based on an object of keypaths. It also accepts an object of customization options for more specific use cases.
10
+
The `createSelector` utility from the [Reselect library](https://github.com/reduxjs/reselect), re-exported for ease of use.
11
11
12
-
For more specifics, see the [`selectorator` usage documentation](https://github.com/planttheidea/selectorator#usage).
12
+
For more details on using `createSelector`, see:
13
13
14
-
```ts
15
-
function createSelector(
16
-
// Can either be:
17
-
// - An array containing selector functions, string keypaths, and argument objects
18
-
// - An object whose keys are selector functions and string keypaths
- The [Reselect API documentation](https://github.com/reduxjs/reselect)
15
+
-[Idiomatic Redux: Using Reselect Selectors for Encapsulation and Performance](https://blog.isquaredsoftware.com/2017/12/idiomatic-redux-using-reselect-selectors/)
16
+
-[React/Redux Links: Reducers and Selectors](https://github.com/markerikson/react-redux-links/blob/master/redux-reducers-selectors.md)
22
17
23
-
Exampleusage:
24
-
25
-
```js
26
-
// Define input selector using a string keypath
27
-
const getSubtotal = createSelector(
28
-
['shop.items'],
29
-
items => {
30
-
// return value here
31
-
}
32
-
)
33
-
34
-
// Define input selectors as a mix of other selectors and string keypaths
35
-
const getTax = createSelector(
36
-
[getSubtotal, 'shop.taxPercent'],
37
-
(subtotal, taxPercent) => {
38
-
// return value here
39
-
}
40
-
)
41
-
42
-
// Define input selector using a custom argument index to access a prop
43
-
const getTabContent = createSelector(
44
-
[{ path: 'tabIndex', argIndex: 1 }],
45
-
tabIndex => {
46
-
// return value here
47
-
}
48
-
)
49
-
50
-
const getContents = createSelector({ foo: 'foo', bar: 'nested.bar' })
51
-
// Returns an object like: {foo, bar}
52
-
```
18
+
> **Note**: Prior to v0.7, RSK re-exported `createSelector` from [`selectorator`](https://github.com/planttheidea/selectorator), which
19
+
> allowed using string keypaths as input selectors. This was removed, as it ultimately did not provide enough benefits, and
20
+
> the string keypaths made static typing for selectors difficult.
0 commit comments