Skip to content

Commit 34893ce

Browse files
committed
v2.0.0 Beta 4 (prescottprue#222)
* Fixes issue with deep listener paths - prescottprue#219, prescottprue#221 * react `v16.0.0-0` added to peer dependencies * Webpack updated to `v3.4.1` * `presence` and `sessions` options support passing a function: ```js { userProfile: 'users', // list of online users organize by group parameter presence: (user) => `presence/${user.group}`, sessions: (user) => `sessions/${user.group}` } ``` * `sessions` option can now be set to null to not writing user sessions when using `presence` * Removed unnecessary constructor from `FirebaseConnect` component * `combineReducers` is now internal instead of being imported from redux (shrinks bundle size and limits dependencies) * [Material-UI example](https://github.com/prescottprue/react-redux-firebase/tree/v2.0.0/examples/complete/material) updates (Navbar state uses auth state instead of profile state)
1 parent 95581ec commit 34893ce

20 files changed

+1386
-402
lines changed

docs/api/connect.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ to provided firebase paths using React's Lifecycle hooks.
4444

4545
**Parameters**
4646

47-
- `props`
48-
- `context`
4947
- `watchArray` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of objects or strings for paths to sync
5048
from Firebase. Can also be a function that returns the array. The function
5149
is passed the current props and the firebase object.

docs/api/constants.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,12 @@ Default configuration options
7171

7272
- `userProfile` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `null` Location on Firebase where user
7373
profiles are stored. Often set to `'users'`.
74-
- `presence` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `null` Location on Firebase where of currently
75-
online users is stored. Often set to `'presence'` or `'onlineUsers'`.
76-
- `sessions` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** `sessions` Location on Firebase where user
74+
- `presence` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function))** `null` Location on Firebase where of currently
75+
online users is stored. Often set to `'presence'` or `'onlineUsers'`. If a function
76+
is passed, the arguments are: `(currentUser, firebase)`.
77+
- `sessions` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function))** `sessions` Location on Firebase where user
7778
sessions are stored (only if presense is set). Often set to `'sessions'` or
78-
`'userSessions'`.
79+
`'userSessions'`. If a function is passed, the arguments are: `(currentUser, firebase)`.
7980
- `enableLogging` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** `false` Whether or not firebase
8081
database logging is enabled.
8182
- `preserveOnLougout` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** `null` Data parameters to preserve when

docs/api/firebaseInstance.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ Sets data to Firebase.
4444
_Basic_
4545

4646
```javascript
47-
import React, { Component, PropTypes } from 'react'
47+
import React, { Component } from 'react'
48+
import PropTypes from 'prop-types'
4849
import { firebaseConnect } from 'react-redux-firebase'
4950
const Example = ({ firebase: { set } }) => (
5051
<button onClick={() => set('some/path', { here: 'is a value' })}>
@@ -86,7 +87,8 @@ Pushes data to Firebase.
8687
_Basic_
8788

8889
```javascript
89-
import React, { Component, PropTypes } from 'react'
90+
import React, { Component } from 'react'
91+
import PropTypes from 'prop-types'
9092
import { firebaseConnect } from 'react-redux-firebase'
9193
const Example = ({ firebase: { push } }) => (
9294
<button onClick={() => push('some/path', true)}>
@@ -126,7 +128,8 @@ Updates data on Firebase and sends new data.
126128
_Basic_
127129

128130
```javascript
129-
import React, { Component, PropTypes } from 'react'
131+
import React, { Component } from 'react'
132+
import PropTypes from 'prop-types'
130133
import { firebaseConnect } from 'react-redux-firebase'
131134
const Example = ({ firebase: { update } }) => (
132135
<button onClick={() => update('some/path', { here: 'is a value' })}>
@@ -166,7 +169,8 @@ Removes data from Firebase at a given path.
166169
_Basic_
167170

168171
```javascript
169-
import React, { Component, PropTypes } from 'react'
172+
import React, { Component } from 'react'
173+
import PropTypes from 'prop-types'
170174
import { firebaseConnect } from 'react-redux-firebase'
171175
const Example = ({ firebase: { remove } }) => (
172176
<button onClick={() => remove('some/path')}>
@@ -181,7 +185,8 @@ Returns **[Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe
181185
## uniqueSet
182186

183187
Sets data to Firebase only if the path does not already
184-
exist, otherwise it rejects.
188+
exist, otherwise it rejects. Internally uses a Firebase transaction to
189+
prevent a race condition between seperate clients calling uniqueSet.
185190

186191
**Parameters**
187192

@@ -194,7 +199,8 @@ exist, otherwise it rejects.
194199
_Basic_
195200

196201
```javascript
197-
import React, { Component, PropTypes } from 'react'
202+
import React, { Component } from 'react'
203+
import PropTypes from 'prop-types'
198204
import { firebaseConnect } from 'react-redux-firebase'
199205
const Example = ({ firebase: { uniqueSet } }) => (
200206
<button onClick={() => uniqueSet('some/unique/path', true)}>

docs/getting_started.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ View the [config section](/config.html) for full list of configuration options.
9696
## Use in Components
9797

9898
```javascript
99-
import React, { Component, PropTypes } from 'react'
99+
import React, { Component } from 'react'
100+
import PropTypes from 'prop-types'
100101
import { connect } from 'react-redux'
101-
import { firebaseConnect, isLoaded, isEmpty, dataToJS } from 'react-redux-firebase'
102+
import { firebaseConnect, isLoaded, isEmpty } from 'react-redux-firebase'
102103

103104
@firebaseConnect([
104105
'todos' // corresponds to 'todos' root on firebase

docs/recipes/actions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export default firebaseConnect()(SimpleComponent)
2626
#### Stateful Component
2727

2828
```js
29-
import React, { Component, PropTypes } from 'react'
29+
import React, { Component } from 'react'
30+
import PropTypes from 'prop-types'
3031
import { firebaseConnect } from 'react-redux-firebase'
3132

3233
@firebaseConnect()

docs/recipes/routing.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Progress on supporting react-router 4 [is tracked within this issue](https://git
1313
Routing can be changed based on data by using react lifecycle hooks such as `componentWillMount`, and `componentWillReceiveProps` to route users. This can be particularly useful when doing things such as route protection (only allowing user to view a route if they are logged in):
1414

1515
```javascript
16-
import React, { Component, PropTypes } from 'react'
16+
import React, { Component } from 'react'
17+
import PropTypes from 'prop-types'
1718
import { connect } from 'react-redux'
1819
import { firebaseConnect, isLoaded, isEmpty } from 'react-redux-firebase'
1920

docs/storage.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ Available on `this.props.firebase` and `getFirebase`.
4343
#### Example
4444

4545
```javascript
46-
import React, { Component, PropTypes } from 'react'
46+
import React, { Component } from 'react'
47+
import PropTypes from 'prop-types'
4748
import { firebaseConnect } from 'react-redux-firebase'
4849

4950
@firebaseConnect()
@@ -79,7 +80,8 @@ Access to Firebase's `storage` is available. This is useful for calling methods
7980
##### File String Upload
8081

8182
```javascript
82-
import React, { Component, PropTypes } from 'react'
83+
import React, { Component } from 'react'
84+
import PropTypes from 'prop-types'
8385
import { firebaseConnect } from 'react-redux-firebase'
8486

8587
@firebaseConnect()

examples/complete/material/src/containers/Navbar/Navbar.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ export default class Navbar extends Component {
6161
}
6262

6363
render () {
64-
const { profile } = this.props
64+
const { profile, auth } = this.props
6565
const profileExists = isLoaded(profile) && !isEmpty(profile)
66+
const authExists = isLoaded(auth) && !isEmpty(auth)
6667

6768
const iconButton = (
6869
<IconButton style={avatarStyles.button} disableTouchRipple>
@@ -93,7 +94,7 @@ export default class Navbar extends Component {
9394
</div>
9495
)
9596

96-
const rightMenu = profileExists ? (
97+
const rightMenu = authExists ? (
9798
<IconMenu
9899
iconButtonElement={iconButton}
99100
targetOrigin={{ horizontal: 'right', vertical: 'bottom' }}
@@ -115,15 +116,15 @@ export default class Navbar extends Component {
115116
<AppBar
116117
title={
117118
<Link
118-
to={accountExists ? `${LIST_PATH}` : '/'}
119+
to={authExists ? `${LIST_PATH}` : '/'}
119120
className={classes.brand}
120121
>
121122
material example
122123
</Link>
123124
}
124125
showMenuIconButton={false}
125126
iconElementRight={rightMenu}
126-
iconStyleRight={profileExists ? avatarStyles.wrapper : {}}
127+
iconStyleRight={authExists ? avatarStyles.wrapper : {}}
127128
className={classes.appBar}
128129
/>
129130
)

examples/snippets/stateBasedQuery/Todos.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import react, { Component, PropTypes } from 'react'
1+
import react, { Component } from 'react'
2+
import PropTypes from 'prop-types'
23
import { connect } from 'react-redux'
34
import {
45
firebaseConnect,

0 commit comments

Comments
 (0)