Skip to content

Commit 44fc5ab

Browse files
authored
v2.0.0-rc.1 (prescottprue#358)
* feat(HOCs): Removed recompose's `withContext` from `withFirebase` and `withFirestore` in order to support react `v16.*.*` - prescottprue#337 * feat(HOCs): `props.dispatch` added to `withFirebase` * feat(core): expose `reducer` as `reducer` to match common redux panther also seen with other libraries such as `redux-form` * fix(storage): `progress: true` option on upload would cause dispatch of `FILE_UPLOAD_START` to occur twice * feat(tests): drastically simplified tests (mostly removing repeated code) while adding more coverage * feat(core): `babel-transform-decorators-legacy` removed from dependencies (no longer used in tests) * feat(core): `recompose` is now a dev dependency only (no longer used in HOCs as part of fix for prescottprue#337)
1 parent 78b14d7 commit 44fc5ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1747
-1110
lines changed

.babelrc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,27 @@
99
}]
1010
],
1111
"plugins": [
12-
["lodash", { "id": ["lodash", "recompose"]}],
12+
["lodash", { "id": ["lodash"]}],
1313
"add-module-exports",
1414
"transform-object-rest-spread",
1515
"transform-object-assign",
16-
"transform-class-properties"
16+
"transform-class-properties",
17+
"transform-export-extensions"
1718
],
1819
"env": {
1920
"es": {
20-
"comments": false
21+
"comments": false,
22+
"plugins": [
23+
]
2124
},
2225
"commonjs": {
23-
"comments": false
26+
"comments": false,
27+
"plugins": [
28+
]
2429
},
2530
"test": {
2631
"plugins": [
2732
"transform-runtime",
28-
"transform-decorators-legacy",
2933
"transform-async-to-generator"
3034
]
3135
}

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ coverage/**
33
node_modules/**
44
_book/**
55
_site/**
6+
test/mocha.opts

docs/api/withFirebase.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
## createWithFirebase
99

1010
Function that creates a Higher Order Component that
11-
automatically listens/unListens to provided firebase paths using
12-
React's Lifecycle hooks.
11+
which provides `firebase` and `dispatch` as a props to React Components.
12+
1313
**WARNING!!** This is an advanced feature, and should only be used when
1414
needing to access a firebase instance created under a different store key.
1515

1616
**Parameters**
1717

1818
- `storeKey` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of redux store which contains
19-
Firebase state (state.firebase) (optional, default `'store'`)
19+
Firebase state (`state.firebase`) (optional, default `'store'`)
2020

2121
**Examples**
2222

@@ -33,15 +33,20 @@ const withFirebase = createWithFirebase('anotherStore')
3333
export default withFirebase(SomeComponent)
3434
```
3535

36-
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** HOC that accepts a watchArray and wraps a component
36+
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Higher Order Component which accepts an array of
37+
watchers config and wraps a React Component
3738

3839
## withFirebase
3940

4041
**Extends React.Component**
4142

42-
Higher Order Component that attaches firebase to props.
43-
Firebase is gathered from store.firebase, which is attached to store by
44-
the store enhancer (reactReduxFirebase) in ./enhancer.
43+
Higher Order Component that provides `firebase` and
44+
`dispatch` as a props to React Components. Firebase is gathered from
45+
`store.firebase`, which is attached to store by the store enhancer
46+
(`reactReduxFirebase`) during setup.
47+
**NOTE**: This version of the Firebase library has extra methods, config,
48+
and functionality which give it it's capabilities such as dispatching
49+
actions.
4550

4651
**Examples**
4752

@@ -60,4 +65,31 @@ const AddData = ({ firebase: { push } }) =>
6065
export default withFirebase(AddData)
6166
```
6267

63-
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** That accepts a component to wrap and returns the wrapped component
68+
_Within HOC Composition_
69+
70+
```javascript
71+
import { compose } from 'redux' // can also come from recompose
72+
import { withHandlers } from 'recompose'
73+
import { withFirebase } from 'react-redux-firebase'
74+
75+
const AddTodo = ({ addTodo }) =>
76+
<div>
77+
<button onClick={addTodo}>
78+
Add Sample Todo
79+
</button>
80+
</div>
81+
82+
export default compose(
83+
withFirebase(AddTodo),
84+
withHandlers({
85+
addTodo: props => () =>
86+
props.firestore.add(
87+
{ collection: 'todos' },
88+
{ done: false, text: 'Sample' }
89+
)
90+
})
91+
)
92+
```
93+
94+
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Which accepts a component to wrap and returns the
95+
wrapped component

docs/api/withFirestore.md

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,90 @@
33
### Table of Contents
44

55
- [createWithFirestore](#createwithfirestore)
6-
- [withFirebase](#withfirebase)
6+
- [withFirestore](#withfirestore)
77

88
## createWithFirestore
99

1010
Function that creates a Higher Order Component that
11-
automatically listens/unListens to provided firebase paths using
12-
React's Lifecycle hooks.
11+
which provides `firebase`, `firestore`, and `dispatch` to React Components.
12+
1313
**WARNING!!** This is an advanced feature, and should only be used when
1414
needing to access a firebase instance created under a different store key.
1515

1616
**Parameters**
1717

1818
- `storeKey` **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** Name of redux store which contains
19-
Firebase state (state.firebase) (optional, default `'store'`)
19+
Firebase state (`state.firebase`) (optional, default `'store'`)
2020

2121
**Examples**
2222

2323
_Basic_
2424

2525
```javascript
26-
// this.props.firebase set on App component as firebase object with helpers
27-
import { createWithFirebase } from 'react-redux-firebase'
26+
import { createWithFirestore } from 'react-redux-firebase'
2827

29-
// create withFirebase that uses another redux store
30-
const withFirebase = createWithFirebase('anotherStore')
28+
// create withFirestore that uses another redux store
29+
const withFirestore = createWithFirestore('anotherStore')
3130

32-
// use the withFirebase to wrap a component
33-
export default withFirebase(SomeComponent)
31+
// use the withFirestore to wrap a component
32+
export default withFirestore(SomeComponent)
3433
```
3534

36-
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** HOC that accepts a watchArray and wraps a component
35+
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Higher Order Component which accepts an array of
36+
watchers config and wraps a React Component
3737

38-
## withFirebase
38+
## withFirestore
3939

4040
**Extends React.Component**
4141

42-
Higher Order Component that attaches firebase to props.
43-
Firebase is gathered from store.firebase, which is attached to store by
44-
the store enhancer (reactReduxFirebase) in ./enhancer.
42+
Higher Order Component that attaches `firestore`, `firebase`
43+
and `dispatch` as props to React Components. Firebase instance is gathered
44+
from `store.firestore`, which is attached to store by the store enhancer
45+
(`reduxFirestore`) during setup of
46+
[`redux-firestore`](https://github.com/prescottprue/redux-firestore)
4547

4648
**Examples**
4749

4850
_Basic_
4951

5052
```javascript
51-
import { withFirebase } from 'react-redux-firebase'
53+
import { withFirestore } from 'react-redux-firebase'
54+
55+
const AddTodo = ({ firestore: { add } }) =>
56+
<div>
57+
<button onClick={() => add('todos', { done: false, text: 'Sample' })}>
58+
Add Sample Todo
59+
</button>
60+
</div>
61+
62+
export default withFirestore(AddTodo)
63+
```
64+
65+
_Within HOC Composition_
66+
67+
```javascript
68+
import { compose } from 'redux' // can also come from recompose
69+
import { withHandlers } from 'recompose'
70+
import { withFirestore } from 'react-redux-firebase'
5271

53-
const AddData = ({ firebase: { push } }) =>
72+
const AddTodo = ({ addTodo }) =>
5473
<div>
55-
<button onClick={() => push('todos', { done: false, text: 'Sample' })}>
74+
<button onClick={addTodo}>
5675
Add Sample Todo
5776
</button>
5877
</div>
5978

60-
export default withFirebase(AddData)
79+
export default compose(
80+
withFirestore(AddTodo),
81+
withHandlers({
82+
addTodo: props => () =>
83+
props.firestore.add(
84+
{ collection: 'todos' },
85+
{ done: false, text: 'Sample' }
86+
)
87+
})
88+
)
6189
```
6290

63-
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** That accepts a component to wrap and returns the wrapped component
91+
Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Which accepts a component to wrap and returns the
92+
wrapped component

0 commit comments

Comments
 (0)