Skip to content

Commit

Permalink
v2.2.6
Browse files Browse the repository at this point in the history
* fix(storage): support only firestore when calling upload and writing - #600, #601
  • Loading branch information
prescottprue committed Jan 1, 2019
2 parents 788b31a + 5074288 commit cb2a56a
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 46 deletions.
12 changes: 5 additions & 7 deletions docs/api/firestoreConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ needing to access a firebase instance created under a different store key.
_Basic_

```javascript
// this.props.firebase set on App component as firebase object with helpers
// props.firebase set on App component as firebase object with helpers
import { createFirestoreConnect } from 'react-redux-firebase'
// create firebase connect that uses another redux store
const firestoreConnect = createFirestoreConnect('anotherStore')
Expand Down Expand Up @@ -53,7 +53,7 @@ attempting to use. **Note** Populate is not yet supported.
_Basic_

```javascript
// this.props.firebase set on App component as firebase object with helpers
// props.firebase set on App component as firebase object with helpers
import { firestoreConnect } from 'react-redux-firebase'
export default firestoreConnect()(SomeComponent)
```
Expand All @@ -64,13 +64,11 @@ _Basic_
import { connect } from 'react-redux'
import { firestoreConnect } from 'react-redux-firebase'

// pass todos list from redux as this.props.todosList
// pass todos list from redux as props.todosList
export default compose(
firestoreConnect(['todos']), // sync todos collection from Firestore into redux
firestoreConnect(() => ['todos']), // sync todos collection from Firestore into redux
connect((state) => ({
todosList: state.firestore.data.todos,
profile: state.firestore.profile, // pass profile data as this.props.profile
auth: state.firestore.auth // pass auth data as this.props.auth
todosList: state.firestore.data.todos
})
)(SomeComponent)
```
Expand Down
40 changes: 24 additions & 16 deletions docs/api/withFirebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ needing to access a firebase instance created under a different store key.
_Basic_

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

// create withFirebase that uses another redux store
Expand Down Expand Up @@ -55,12 +55,15 @@ _Basic_
```javascript
import { withFirebase } from 'react-redux-firebase'

const AddData = ({ firebase: { push } }) =>
<div>
<button onClick={() => push('todos', { done: false, text: 'Sample' })}>
Add Sample Todo
</button>
</div>
function AddData({ firebase: { push } }) {
return (
<div>
<button onClick={() => push('todos', { done: false, text: 'Sample' })}>
Add Sample Todo
</button>
</div>
)
}

export default withFirebase(AddData)
```
Expand All @@ -72,15 +75,18 @@ import { compose } from 'redux' // can also come from recompose
import { withHandlers } from 'recompose'
import { withFirebase } from 'react-redux-firebase'

const AddTodo = ({ addTodo }) =>
<div>
<button onClick={addTodo}>
Add Sample Todo
</button>
</div>

export default compose(
withFirebase(AddTodo),
function AddTodo({ addTodo }) {
return (
<div>
<button onClick={addTodo}>
Add Sample Todo
</button>
</div>
)
}

const enhance = compose(
withFirebase,
withHandlers({
addTodo: props => () =>
props.firestore.add(
Expand All @@ -89,6 +95,8 @@ export default compose(
)
})
)

export default enhance(AddTodo)
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Which accepts a component to wrap and returns the
Expand Down
51 changes: 30 additions & 21 deletions docs/api/withFirestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ needing to access a firebase instance created under a different store key.
**Parameters**

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

**Examples**

Expand Down Expand Up @@ -50,42 +50,51 @@ from `store.firestore`, which is attached to store by the store enhancer
_Basic_

```javascript
import React from 'react'
import { withFirestore } from 'react-redux-firebase'

const AddTodo = ({ firestore: { add } }) =>
<div>
<button onClick={() => add('todos', { done: false, text: 'Sample' })}>
Add Sample Todo
</button>
</div>
function AddData({ firebase: { add } }) {
return (
<div>
<button onClick={() => add('todos', { done: false, text: 'Sample' })}>
Add Sample Todo
</button>
</div>
)
}

export default withFirestore(AddTodo)
```

_Within HOC Composition_

```javascript
import React from 'react'
import { compose } from 'redux' // can also come from recompose
import { withHandlers } from 'recompose'
import { withFirestore } from 'react-redux-firebase'

const AddTodo = ({ addTodo }) =>
<div>
<button onClick={addTodo}>
Add Sample Todo
</button>
</div>

export default compose(
withFirestore(AddTodo),
function AddTodo({ addTodo }) {
return (
<div>
<button onClick={addTodo}>
Add Sample Todo
</button>
</div>
)
}

const enhance = compose(
withFirestore,
withHandlers({
addTodo: props => () =>
props.firestore.add(
{ collection: 'todos' },
{ done: false, text: 'Sample' }
)
addTodo: props => () => {
const newTodo = { done: false, text: 'Sample' }
return props.firestore.add({ collection: 'todos' }, newTodo)
}
})
)

export default enhance(AddTodo)
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Which accepts a component to wrap and returns the
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-redux-firebase",
"version": "2.2.5",
"version": "2.2.6",
"description": "Redux integration for Firebase. Comes with a Higher Order Components for use with React.",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/actions/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const uploadFile = (dispatch, firebase, config) => {

return uploadPromise()
.then(uploadTaskSnapshot => {
if (!dbPath || !firebase.database) {
if (!dbPath || (!firebase.database && !firebase.firestore)) {
dispatch({
type: FILE_UPLOAD_COMPLETE,
meta: { ...config, filename },
Expand Down

0 comments on commit cb2a56a

Please sign in to comment.