Skip to content

Commit 78171b9

Browse files
authored
v2.4.1
* chore(deps): update to lodash to 4.17.15 * chore(deps): update proptypes to 15.7.2 * docs(integrations): add docs for how to reference data from state for reselect selectors - #614
1 parent c1b1b89 commit 78171b9

File tree

5 files changed

+58
-12
lines changed

5 files changed

+58
-12
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ View docs for recipes on integrations with:
304304

305305
* [redux-firestore](http://react-redux-firebase.com/docs/firestore.html)
306306
* [redux-thunk](http://react-redux-firebase.com/docs/integrations/thunks.html)
307+
* [reselect](http://react-redux-firebase.com/docs/integrations/integrations/reselect.html)
307308
* [redux-observable](http://react-redux-firebase.com/docs/integrations/redux-observable.html)
308309
* [redux-saga](http://react-redux-firebase.com/docs/integrations/redux-saga.html)
309310
* [redux-form](http://react-redux-firebase.com/docs/integrations/redux-form.html)

SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* [Integrations](/docs/integrations/README.md)
2121
* [Redux Thunk](/docs/integrations/thunks.md)
2222
* [Redux Form](/docs/integrations/redux-form.md)
23+
* [Reselect](/docs/integrations/reselect.md)
2324
* [Redux Persist](/docs/integrations/redux-persist.md)
2425
* [Redux Saga](/docs/integrations/redux-saga.md)
2526
* [Redux Observable](/docs/integrations/redux-observable.md)

docs/integrations/reselect.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Reselect
2+
3+
There are a number of reasons to use state selectors, as mentioned in the [relesect docs](https://github.com/reduxjs/reselect):
4+
5+
> * Selectors can compute derived data, allowing Redux to store the minimal possible state.
6+
> * Selectors are efficient. A selector is not recomputed unless one of its arguments changes.
7+
> * Selectors are composable. They can be used as input to other selectors.
8+
9+
For more information, about why this is important, checkout the [motivation for memoized selectors sections of the reselect docs](https://github.com/reduxjs/reselect#motivation-for-memoized-selectors)
10+
11+
## State Selectors
12+
13+
Select only what you need from state in your selectors instead of the whole firebase/firestore state object:
14+
15+
```js
16+
import { createSelector } from 'reselect';
17+
import { connect } from 'react-redux'
18+
import { get, sumBy } from 'lodash'
19+
20+
const netTotalSelector = createSelector(
21+
state => get(state, 'firestore.data.products'),
22+
products => sumBy(products, 'price')
23+
)
24+
25+
connect((state) => ({
26+
netTotal: netTotalSelector(state)
27+
}))(Component)
28+
```
29+
30+
In this case Reselect will memoize the products object. That means that even if there's any update to other parts of redux state (including firebase/firestore), the memoized products object will stay the same until there is an update to the products themselves.
31+
32+
See [issue #614](https://github.com/prescottprue/react-redux-firebase/issues/614) for more info.

package-lock.json

Lines changed: 21 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "2.4.0",
3+
"version": "2.4.1",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Components for use with React.",
55
"main": "lib/index.js",
66
"module": "es/index.js",
@@ -59,8 +59,8 @@
5959
],
6060
"dependencies": {
6161
"hoist-non-react-statics": "^3.3.0",
62-
"lodash": "^4.17.11",
63-
"prop-types": "^15.6.2"
62+
"lodash": "^4.17.15",
63+
"prop-types": "^15.7.2"
6464
},
6565
"peerDependencies": {
6666
"react": "^0.14.6 || ^15.0.0-0 || ^16.0.0-0"

0 commit comments

Comments
 (0)