-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(auth): remove signIn option from createUser (new user is automatically signed in through Firebase SDK) - #513 * docs(perf): document the correct way reference to state.firestore when creating selectors - #614 * chore(deps): update lodash to 4.17.15
- Loading branch information
Scott Prue
committed
Sep 3, 2019
1 parent
e8e93b8
commit 07bcd58
Showing
8 changed files
with
79 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Reselect | ||
|
||
There are a number of reasons to use state selectors, as mentioned in the [relesect docs](https://github.com/reduxjs/reselect): | ||
|
||
> * Selectors can compute derived data, allowing Redux to store the minimal possible state. | ||
> * Selectors are efficient. A selector is not recomputed unless one of its arguments changes. | ||
> * Selectors are composable. They can be used as input to other selectors. | ||
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) | ||
|
||
## State Selectors | ||
|
||
Select only what you need from state in your selectors instead of the whole firebase/firestore state object: | ||
|
||
```js | ||
import { createSelector } from 'reselect'; | ||
import { connect } from 'react-redux' | ||
import { get, sumBy } from 'lodash' | ||
|
||
const netTotalSelector = createSelector( | ||
state => get(state, 'firestore.data.products'), | ||
products => sumBy(products, 'price') | ||
) | ||
|
||
connect((state) => ({ | ||
netTotal: netTotalSelector(state) | ||
}))(Component) | ||
``` | ||
|
||
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. | ||
|
||
See [issue #614](https://github.com/prescottprue/react-redux-firebase/issues/614) for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters