Skip to content

Commit 5e257e8

Browse files
author
Scott Prue
committed
Merge branch 'master' into next
2 parents a997612 + 011d245 commit 5e257e8

File tree

4 files changed

+26
-54
lines changed

4 files changed

+26
-54
lines changed

docs/api/connect.md

+12-28
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ import { firebaseConnect } from 'react-redux-firebase'
5656
export default firebaseConnect()(App)
5757
```
5858

59-
_Data_
59+
_Ordered Data_
6060

6161
```javascript
6262
import { compose } from 'redux'
@@ -71,56 +71,40 @@ const enhance = compose(
7171
todos: state.firebase.ordered.todos
7272
})
7373
)
74+
7475
// use enhnace to pass todos list as props.todos
7576
const Todos = enhance(({ todos })) =>
7677
<div>
7778
{JSON.stringify(todos, null, 2)}
7879
</div>
7980
)
81+
82+
export default enhance(Todos)
8083
```
8184

8285
_Data that depends on props_
8386

8487
```javascript
8588
import { compose } from 'redux'
8689
import { connect } from 'react-redux'
87-
import { firebaseConnect } from 'react-redux-firebase'
90+
import { firebaseConnect, getVal } from 'react-redux-firebase'
8891

8992
const enhance = compose(
9093
firebaseConnect((props) => ([
9194
`posts/${props.postId}` // sync /posts/postId from firebase into redux
9295
]),
93-
connect(({ firebase: { data } }, props) => ({
94-
todo: data.posts && data.todos[postId],
96+
connect((state, props) => ({
97+
post: getVal(state.firebase.data, `posts/${props.postId}`),
9598
})
9699
)
97100

98-
const Posts = ({ done, text, author }) => (
99-
<article>
100-
<h1>{title}</h1>
101-
<h2>By {author.name}</h2>
102-
<div>{content}</div>
103-
</article>
101+
const Post = ({ post }) => (
102+
<div>
103+
{JSON.stringify(post, null, 2)}
104+
</div>
104105
)
105106

106-
export default enhance(Posts)
107-
```
108-
109-
_Data that depends on state_
110-
111-
```javascript
112-
import { compose } from 'redux'
113-
import { connect } from 'react-redux'
114-
import { firebaseConnect } from 'react-redux-firebase'
115-
116-
export default compose(
117-
firebaseConnect((props, store) => ([
118-
`todos/${store.getState().firebase.auth.uid}`
119-
]),
120-
connect(({ firebase: { data, auth } }) => ({
121-
todosList: data.todos && data.todos[auth.uid],
122-
}))
123-
)(SomeComponent)
107+
export default enhance(Post)
124108
```
125109
126110
Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** that accepts a component to wrap and returns the wrapped component

docs/api/enhancer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ along side applyMiddleware.
2727
profile when logging in. (default: `true`)
2828
- `config.resetBeforeLogin` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether or not to empty profile
2929
and auth state on login
30-
- `config.perserveOnLogout` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** Data parameters to perserve
30+
- `config.preserveOnLogout` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array))** Data parameters to preserve
3131
when logging out. If Array is passed, each item represents keys
3232
within `state.firebase.data` to preserve. If an object is passed,
3333
keys associate with slices of state to preserve, and the values can be either

src/enhancer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let firebaseInstance
2626
* profile when logging in. (default: `true`)
2727
* @param {Boolean} config.resetBeforeLogin - Whether or not to empty profile
2828
* and auth state on login
29-
* @param {Object|Array} config.perserveOnLogout - Data parameters to perserve
29+
* @param {Object|Array} config.preserveOnLogout - Data parameters to preserve
3030
* when logging out. If Array is passed, each item represents keys
3131
* within `state.firebase.data` to preserve. If an object is passed,
3232
* keys associate with slices of state to preserve, and the values can be either

src/firebaseConnect.js

+12-24
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const createFirebaseConnect = (storeKey = 'store') => (
111111
* // props.firebase set on App component as firebase object with helpers
112112
* import { firebaseConnect } from 'react-redux-firebase'
113113
* export default firebaseConnect()(App)
114-
* @example <caption>Data</caption>
114+
* @example <caption>Ordered Data</caption>
115115
* import { compose } from 'redux'
116116
* import { connect } from 'react-redux'
117117
* import { firebaseConnect } from 'react-redux-firebase'
@@ -124,47 +124,35 @@ export const createFirebaseConnect = (storeKey = 'store') => (
124124
* todos: state.firebase.ordered.todos
125125
* })
126126
* )
127+
*
127128
* // use enhnace to pass todos list as props.todos
128129
* const Todos = enhance(({ todos })) =>
129130
* <div>
130131
* {JSON.stringify(todos, null, 2)}
131132
* </div>
132133
* )
134+
*
135+
* export default enhance(Todos)
133136
* @example <caption>Data that depends on props</caption>
134137
* import { compose } from 'redux'
135138
* import { connect } from 'react-redux'
136-
* import { firebaseConnect } from 'react-redux-firebase'
139+
* import { firebaseConnect, getVal } from 'react-redux-firebase'
137140
*
138141
* const enhance = compose(
139142
* firebaseConnect((props) => ([
140143
* `posts/${props.postId}` // sync /posts/postId from firebase into redux
141144
* ]),
142-
* connect(({ firebase: { data } }, props) => ({
143-
* todo: data.posts && data.todos[postId],
145+
* connect((state, props) => ({
146+
* post: getVal(state.firebase.data, `posts/${props.postId}`),
144147
* })
145148
* )
146149
*
147-
* const Posts = ({ done, text, author }) => (
148-
* <article>
149-
* <h1>{title}</h1>
150-
* <h2>By {author.name}</h2>
151-
* <div>{content}</div>
152-
* </article>
150+
* const Post = ({ post }) => (
151+
* <div>
152+
* {JSON.stringify(post, null, 2)}
153+
* </div>
153154
* )
154155
*
155-
* export default enhance(Posts)
156-
* @example <caption>Data that depends on state</caption>
157-
* import { compose } from 'redux'
158-
* import { connect } from 'react-redux'
159-
* import { firebaseConnect } from 'react-redux-firebase'
160-
*
161-
* export default compose(
162-
* firebaseConnect((props, store) => ([
163-
* `todos/${store.getState().firebase.auth.uid}`
164-
* ]),
165-
* connect(({ firebase: { data, auth } }) => ({
166-
* todosList: data.todos && data.todos[auth.uid],
167-
* }))
168-
* )(SomeComponent)
156+
* export default enhance(Post)
169157
*/
170158
export default createFirebaseConnect()

0 commit comments

Comments
 (0)