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
-[`react-native` support](/docs/recipes/react-native.md) using [native modules](/docs/recipes/react-native.md#native-modules) or [web sdk](/docs/recipes/react-native.md#jsweb)
35
35
36
36
## Install
37
+
37
38
```bash
38
39
npm install --save react-redux-firebase
39
40
```
41
+
#### Other Versions
40
42
41
-
## Before Use
42
-
43
-
### Peer Dependencies
44
-
45
-
Install peer dependencies: `npm i --save redux react-redux`
46
-
47
-
### Decorators
48
-
49
-
Though they are optional, it is highly recommended that you use 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.
50
-
51
-
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:
43
+
The above install command will install the `@latest` tag. You may also use the following tags when installing to get different versions:
52
44
53
-
#### Without Decorators
54
-
```javascript
55
-
classSomeComponentextendsComponent {
45
+
<!-- `@next` - Next upcoming release. currently points to active progress with `v1.5.0-*` pre-releases -->
46
+
`@canary` - Most possible up to date code. Currently points to active progress with `v2.0.0-*` pre-releases. *Warning:* Syntax is different than current stable version.
56
47
57
-
}
58
-
exportdefaultconnect()(SomeComponent)
59
-
```
60
-
vs.
61
-
62
-
#### With Decorators
63
-
```javascript
64
-
@connect()
65
-
exportdefaultclassSomeComponentextendsComponent {
66
-
67
-
}
68
-
```
69
-
70
-
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:
71
-
72
-
1. run `npm i --save-dev babel-plugin-transform-decorators-legacy`
73
-
2. Add the following line to your `.babelrc`:
74
-
```
75
-
{
76
-
"plugins": ["transform-decorators-legacy"]
77
-
}
78
-
```
48
+
**Note:** Be careful using no-stable versions. Try to keep an eye on the [releases page](https://github.com/prescottprue/react-redux-firebase/releases) for relevant release info.
79
49
80
50
## Use
81
51
82
-
Include reduxFirebase in your store compose function:
83
-
52
+
Include `reactReduxFirebase` in your store compose function and `firebaseStateReducer` in your reducers:
Firebase's library requires XML request capability, so if you are using `react-redux-firebase` in a Server Side rendering environment, make sure you require `xmlhttprequest`.
176
+
Though they are optional, it is highly recommended that you use 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.
192
177
193
-
If you disagree with having to do this yourself, hop [on gitter](https://gitter.im/redux-firebase/Lobby) and let us know!
178
+
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:
179
+
180
+
#### Without Decorators
181
+
```javascript
182
+
classSomeComponentextendsComponent {
183
+
184
+
}
185
+
exportdefaultconnect()(SomeComponent)
186
+
```
187
+
vs.
188
+
189
+
#### With Decorators
190
+
```javascript
191
+
@connect()
192
+
exportdefaultclassSomeComponentextendsComponent {
193
+
194
+
}
195
+
```
196
+
197
+
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:
194
198
195
-
```js
196
-
// needed to fix "Error: The XMLHttpRequest compatibility library was not found."
Examples folder is broken into two categories [complete](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/complete) and [snippets](https://github.com/prescottprue/react-redux-firebase/tree/master/examples/snippets). `/complete` contains full applications that can be run as is, while `/snippets` contains small amounts of code to show functionality (dev tools and deps not included).
@@ -230,118 +242,17 @@ An example that user Material UI built on top of the output of [create-react-app
230
242
231
243
Join us on the [redux-firebase gitter](https://gitter.im/redux-firebase/Lobby).
232
244
233
-
## Using With Other Libraries
234
-
235
-
### redux-thunk
236
-
If you are using `redux-thunk`, make sure to set up your thunk middleware using it's redux-thunk's `withExtraArgument` method so that firebase is available within your actions. Here is an example `createStore` function that adds `getFirebase` as third argument along with a thunk that uses it:
thunk.withExtraArgument(getFirebase) // Pass getFirebase function as extra argument
257
-
]),
258
-
reactReduxFirebase(fbConfig, config)
259
-
)
260
-
);
261
-
262
-
```
263
-
Action:
264
-
265
-
```javascript
266
-
import { pathToJS } from'react-redux-firebase'
267
-
268
-
exportconstaddTodo= (newTodo) =>
269
-
(dispatch, getState, getFirebase) => {
270
-
constauth=pathToJS(getState.firebase, 'auth')
271
-
newTodo.createdBy=auth.uid//
272
-
getFirebase()
273
-
.push('todos', newTodo)
274
-
// using pushWithMeta instead would attach createdBy and createdAt automatically
275
-
.then(() => {
276
-
dispatch({
277
-
type:'TODO_CREATED',
278
-
payload: newTodo
279
-
})
280
-
})
281
-
};
282
-
283
-
```
284
-
285
-
### redux-observable
286
-
If you are using `redux-observable`, make sure to set up your redux-observable middleware so that firebase is available within your epics. Here is an example `combineEpics` function that adds `getFirebase` as third argument along with an epic that uses it:
Special thanks to [Tiberiu Craciun](https://github.com/tiberiuc) for creating [redux-react-firebase](https://github.com/tiberiuc/redux-react-firebase), which this project was originally based on.
0 commit comments