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
* feat(populate): `childAlias` for store results of populate on another parameter - #126
* feat(profile): Firestore support for `updateProfile` method - [issue 25 on redux-firestore](prescottprue/redux-firestore#25)
* feat(storage): `progress` option added to `uploadFile` method - #346
* feat(storage): `uploadFile` default metadata written to DB now includes `createdAt`
* feat(core): `redux-firestore` is no longer a dependency - managed by library user directly
* fix(examples): Material-ui example updates (including moving `injectTapEventPlugin()` to `main.js`)
Install peer dependencies: `npm i --save redux react-redux`
13
13
14
-
### Decorators
15
-
16
-
Though they are optional, it is highly recommended that you used decorators with this library. [The Simple Example](examples/simple) shows implementation without decorators, while [the Decorators Example](examples/decorators) shows the same application with decorators implemented.
17
-
18
-
A side by side comparison using [react-redux](https://github.com/reactjs/react-redux)'s `connect` function/HOC is the best way to illustrate the difference:
19
-
20
-
```jsx
21
-
classSomeComponentextendsComponent {
22
-
23
-
}
24
-
exportdefaultconnect()(SomeComponent)
25
-
```
26
-
vs.
27
-
28
-
```jsx
29
-
@connect()
30
-
exportdefaultclassSomeComponentextendsComponent {
31
-
32
-
}
33
-
```
34
-
35
-
In order to enable this functionality, you will most likely need to install a plugin (depending on your build setup). For Webpack and Babel, you will need to make sure you have installed and enabled [babel-plugin-transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) by doing the following:
36
-
37
-
1. run `npm i --save-dev babel-plugin-transform-decorators-legacy`
38
-
2. Add the following line to your `.babelrc`:
39
-
```json
40
-
{
41
-
"plugins": ["transform-decorators-legacy"]
42
-
}
43
-
```
44
-
45
-
46
14
## Install
47
15
```bash
48
16
npm install --save react-redux-firebase
@@ -55,15 +23,15 @@ Include `firebase` in your combine reducers function:
They are completely optional, but ES7 Decorators can be used. [The Simple Example](examples/simple) shows implementation without decorators, while [the Decorators Example](examples/decorators) shows the same application with decorators implemented.
94
+
95
+
A side by side comparison using [react-redux](https://github.com/reactjs/react-redux)'s `connect` function/HOC is the best way to illustrate the difference:
96
+
97
+
```jsx
98
+
classSomeComponentextendsComponent {
99
+
154
100
}
101
+
exportdefaultconnect()(SomeComponent)
155
102
```
103
+
vs.
156
104
157
-
Alternatively, if you choose not to use decorators, your connect function will look like so:
105
+
```jsx
106
+
@connect()
107
+
exportdefaultclassSomeComponentextendsComponent {
158
108
159
-
```javascript
160
-
constwrappedTodos=firebaseConnect([
161
-
'todos'
162
-
])(Todos)
109
+
}
110
+
```
163
111
164
-
exportdefaultconnect(
165
-
({ firebase: { data: { todos } } }) => ({
166
-
todos,
167
-
})
168
-
)(wrappedTodos)
112
+
In order to enable this functionality, you will most likely need to install a plugin (depending on your build setup). For Webpack and Babel, you will need to make sure you have installed and enabled [babel-plugin-transform-decorators-legacy](https://github.com/loganfsmyth/babel-plugin-transform-decorators-legacy) by doing the following:
169
113
114
+
1. run `npm i --save-dev babel-plugin-transform-decorators-legacy`
1.`firebaseConnect` - based on populate settings, queries are created for associated keys to be replaced. Query results are stored in redux under the value of `root` in the populate settings.
36
36
2.`connect` - Combine original data at path with all populate data (in redux from queries created by passing populate settings to `firebaseConnect`)
37
-
* Populate creates a query for each key that is being replaced
37
+
* Populate creates a query for each key that is being "populated", but does not create multiple queries for the same key
38
38
* Results of populate queries are placed under their root
39
39
40
40
## Examples
@@ -135,10 +135,13 @@ ASDF123: {
135
135
}
136
136
```
137
137
138
-
##### Keep Object's Key
138
+
##### Keep Object's Key {#keyProp}
139
139
140
140
Often when populating, you will want to keep the key that was originally there (before being replaced by populated value). This is supported through the use of `keyProp`:
141
141
142
+
143
+
*NOTE:* Similar results also be accomplished using [`childAlias`](#childAlias) since child (key in this case) will be preserved if populate result is "aliased"
144
+
142
145
##### Example Query
143
146
```javascript
144
147
constpopulates= [
@@ -170,7 +173,44 @@ ASDF123: {
170
173
}
171
174
```
172
175
173
-
### Object's Parameter
176
+
### Place Result On Another Parameter {#childAlias}
177
+
178
+
There is also the option to place the results of a populate on another parameter instead of replacing the original child (i.e. "alias" the child result). An example of this could be populating the `owner` parameter onto the `ownerObj` parameter, which would leave the `owner` parameter intact (since the child from the populate was "aliased" to `ownerObj`).
179
+
180
+
For more details including the initial feature request, checkout [issue #126](https://github.com/prescottprue/react-redux-firebase/issues/126).
There is also the option to load a parameter from within a population object. An example of this could be populating the `owner` parameter with the `email` property of the `user` with a matching ID:
0 commit comments