Skip to content

Commit 5e8b004

Browse files
docs(store): add selector deprecation in v12 migration (ngrx#3015)
1 parent 5259890 commit 5e8b004

File tree

1 file changed

+44
-2
lines changed
  • projects/ngrx.io/content/guide/migration

1 file changed

+44
-2
lines changed

projects/ngrx.io/content/guide/migration/v12.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,48 @@ Version 12 has the minimum version requirements:
1919
- TypeScript version 4.2.x
2020
- RxJS version 6.5.x
2121

22-
## Breaking changes
22+
## Deprecations
2323

24-
TBD
24+
### @ngrx/store
25+
26+
#### Selectors With Props
27+
28+
Selectors with props are deprecated in favor of "normal" factory selectors.
29+
Factory selectors have the following benefits:
30+
31+
- easier to write and to teach
32+
- selectors are typed
33+
- child selectors are correctly memoized
34+
35+
BEFORE:
36+
37+
```ts
38+
const selectCustomer = createSelector(
39+
selectCustomers,
40+
(customers, props: { customerId: number }) => {
41+
return customers[customerId];
42+
}
43+
);
44+
45+
// Or if the selector is already defined as a factory selector
46+
47+
const selectCustomer = () =>
48+
createSelector(
49+
selectCustomers,
50+
(customers, props: { customerId: number }) => {
51+
return customers[customerId];
52+
}
53+
);
54+
```
55+
56+
AFTER:
57+
58+
```ts
59+
const selectCustomer = (customerId: number) =>
60+
createSelector(
61+
selectCustomers,
62+
(customers) => {
63+
return customers[customerId];
64+
}
65+
);
66+
```

0 commit comments

Comments
 (0)