Skip to content

Commit

Permalink
v3.0.0-alpha.16
Browse files Browse the repository at this point in the history
* fix(examples): switch to next in simple example with new version of react-redux
* fix(types): make options param optional in `updateProfile` - #749 - @rscotten
* feat(HOCs): remove `createFirestoreConnect` and `createFirebaseConnect` - store selection is no longer necessary
* fix(types): add descriptions for main methods
* fix(types): remove no longer exported functions from types
* feat(tests): replace [`istanbul`](https://www.npmjs.com/package/istanbul) with [`nyc`](https://www.npmjs.com/package/nyc)
  • Loading branch information
prescottprue committed Aug 15, 2019
1 parent eb5efe2 commit e8e93b8
Show file tree
Hide file tree
Showing 27 changed files with 11,737 additions and 16,350 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ examples/**/node_modules
_book/**
_site/**
coverage
.nyc_output
dist
es
lib
Expand Down
32 changes: 2 additions & 30 deletions docs/api/firebaseConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,8 @@

### Table of Contents

- [createFirebaseConnect](#createfirebaseconnect)
- [firebaseConnect](#firebaseconnect)

## createFirebaseConnect

Function that creates a Higher Order Component which
automatically listens/unListens to provided firebase paths using
React's Lifecycle hooks.
**WARNING!!** This is an advanced feature, and should only be used when
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'`)

**Examples**

_Basic_

```javascript
// props.firebase set on App component as firebase object with helpers
import { createFirebaseConnect } from 'react-redux-firebase'
// create firebase connect that uses another redux store
const firebaseConnect = createFirebaseConnect('anotherStore')
// use the firebaseConnect to wrap a component
export default firebaseConnect()(SomeComponent)
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** HOC that accepts a watchArray and wraps a component

## firebaseConnect

**Extends React.Component**
Expand All @@ -42,6 +13,7 @@ to provided firebase paths using React's Lifecycle hooks.

**Parameters**

- `dataOrFn` (optional, default `[]`)
- `watchArray` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of objects or strings for paths to sync
from Firebase. Can also be a function that returns the array. The function
is passed the current props and the firebase object.
Expand Down Expand Up @@ -99,7 +71,7 @@ const enhance = compose(
])),
connect((state, props) => ({
post: get(state.firebase.data, `posts.${props.postId}`),
})
}))
)

function Post({ post }) {
Expand Down
30 changes: 1 addition & 29 deletions docs/api/firestoreConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,8 @@

### Table of Contents

- [createFirestoreConnect](#createfirestoreconnect)
- [firestoreConnect](#firestoreconnect)

## createFirestoreConnect

Function that creates a Higher Order Component which
automatically listens/unListens to provided firebase paths using
React's Lifecycle hooks.
**WARNING!!** This is an advanced feature, and should only be used when
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'`)

**Examples**

_Basic_

```javascript
// 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')
// use the firebaseConnect to wrap a component
export default firestoreConnect()(SomeComponent)
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** HOC that accepts a watchArray and wraps a component

## firestoreConnect

**Extends React.Component**
Expand All @@ -44,6 +15,7 @@ attempting to use. **Note** Populate is not yet supported.

**Parameters**

- `dataOrFn` (optional, default `[]`)
- `queriesConfig` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array of objects or strings for paths to sync
from Firebase. Can also be a function that returns the array. The function
is passed the current props and the firebase object.
Expand Down
2 changes: 1 addition & 1 deletion docs/api/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const enhance = compose(
connect(({ firebase }) => ({
// this.props.todos loaded from state.firebase.data.todos
todos: getVal(firebase, 'data/todos/user1', defaultValue)
})
}))
)

export default enhance(SomeComponent)
Expand Down
48 changes: 9 additions & 39 deletions docs/api/useFirebaseConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,8 @@

### Table of Contents

- [createUseFirebaseConnect](#createusefirebaseconnect)
- [useFirebaseConnect](#usefirebaseconnect)

## createUseFirebaseConnect

Function that creates a hook that
automatically listens/unListens to provided firebase paths using
React's useEffect hooks.
**WARNING!!** This is an advanced feature, and should only be used when
needing to access a firebase instance created under a different store key.

**Examples**

_Basic_

```javascript
// this.props.firebase set on App component as firebase object with helpers
import { createUseFirebaseConnect } from 'react-redux-firebase'
// create firebase connect that uses another redux store
const useFirebaseConnect = createUseFirebaseConnect()
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** HOC that accepts a watchArray and wraps a component

## useFirebaseConnect

Hook that automatically listens/unListens
Expand Down Expand Up @@ -70,17 +48,12 @@ _Data that depends on props_

```javascript
import { compose } from 'redux'
import { connect } from 'react-redux'
import { firebaseUseConnect, getVal } from 'react-redux-firebase'

const enhance = compose(
connect((state, props) => ({
post: getVal(state.firebase.data, `posts/${props.postId}`),
}))
)
import { useSelector } from 'react-redux'
import { firebaseUseConnect } from 'react-redux-firebase'

function Post({ post, postId }) {
function Post({ postId }) {
useFirebaseConnect(`posts/${postId}`) // sync /posts/postId from firebase into redux
const post = useSelector(({ firebase }) => state.firebase.ordered.posts && state.firebase.ordered.posts[postId])
return (
<div>
{JSON.stringify(post, null, 2)}
Expand All @@ -95,23 +68,20 @@ _Data that depends on props, an array as a query_

```javascript
import { compose } from 'redux'
import { connect } from 'react-redux'
import { useSelector } from 'react-redux'
import { firebaseUseConnect, getVal } from 'react-redux-firebase'

const enhance = compose(
connect((state, props) => ({
post: getVal(state.firebase.data, `posts/${props.postId}`),
}))
)

function Post({ post, postId }) {
useFirebaseConnect([`posts/${postId}`], [postId]) // sync /posts/postId from firebase into redux
const post = useSelector(state => {
return state.firebase.ordered.posts && state.firebase.ordered.posts[postId]
})
return (
<div>
{JSON.stringify(post, null, 2)}
</div>
)
}

export default enhance(Post)
export default Post
```
46 changes: 11 additions & 35 deletions docs/api/useFirestoreConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,8 @@

### Table of Contents

- [createUseFirestoreConnect](#createusefirestoreconnect)
- [useFirestoreConnect](#usefirestoreconnect)

## createUseFirestoreConnect

React hook that automatically listens/unListens to provided
firestore paths.
**WARNING!!** This is an advanced feature, and should only be used when
needing to access a firebase instance created under a different store key.
Firebase state (state.firestore)

**Examples**

_Basic_

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

const firestoreConnect = createUseFirestoreConnect()

export default useFirestoreConnect()
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** React hook that accepts watch query

## useFirestoreConnect

React hook that automatically listens/unListens
Expand All @@ -48,21 +24,21 @@ _Basic_
```javascript
import React from 'react'
import { map } from 'lodash'
import { connect } from 'react-redux'
import { useSelector } from 'react-redux'
import { useFirebaseConnect } from 'react-redux-firebase'

function TodosList({ todosList }) {
function TodosList() {
useFirebaseConnect('todos') // sync todos collection from Firestore into redux

return <ul>{_.map(todosList, todo => <li>{todo}</li>)}</ul>
const todos = useSelector(state => state.firebase.data.todos)
return (
<ul>
{map(todos, (todo, todoId) => (
<li>id: {todoId} todo: {JSON.stringify(todo)}</li>
))}
</ul>
)
}

// pass todos list from redux as props.todosList
export default compose(
connect((state) => ({
todosList: state.firestore.data.todos
})
)(TodosList)
export default TodosList
```

_Object as query_
Expand Down
32 changes: 0 additions & 32 deletions docs/api/withFirebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,8 @@

### Table of Contents

- [createWithFirebase](#createwithfirebase)
- [withFirebase](#withfirebase)

## createWithFirebase

Function that creates a Higher Order Component that
which provides `firebase` and `dispatch` as a props to React Components.

**WARNING!!** This is an advanced feature, and should only be used when
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'`)

**Examples**

_Basic_

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

// create withFirebase that uses another redux store
const withFirebase = createWithFirebase('anotherStore')

// use the withFirebase to wrap a component
export default withFirebase(SomeComponent)
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Higher Order Component which accepts an array of
watchers config and wraps a React Component

## withFirebase

**Extends React.Component**
Expand Down
31 changes: 0 additions & 31 deletions docs/api/withFirestore.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,8 @@

### Table of Contents

- [createWithFirestore](#createwithfirestore)
- [withFirestore](#withfirestore)

## createWithFirestore

Function that creates a Higher Order Component that
which provides `firebase`, `firestore`, and `dispatch` to React Components.

**WARNING!!** This is an advanced feature, and should only be used when
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
Firestore state (`state.firestore`) (optional, default `'store'`)

**Examples**

_Basic_

```javascript
import { createWithFirestore } from 'react-redux-firebase'

// create withFirestore that uses another redux store
const withFirestore = createWithFirestore('anotherStore')

// use the withFirestore to wrap a component
export default withFirestore(SomeComponent)
```

Returns **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Higher Order Component which accepts an array of
watchers config and wraps a React Component

## withFirestore

**Extends React.Component**
Expand Down
12 changes: 11 additions & 1 deletion docs/v3-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@
## What Changed

* Support `react-redux` v6 and new React Context API - [#581](https://github.com/prescottprue/react-redux-firebase/issues/581). This mean no more `reactReduxFirebase` and `reduxFirestore` store enhancers (instance is passed through the new React context API) - [#581](https://github.com/prescottprue/react-redux-firebase/issues/581)
* `componentDidMount` used in place of `componentWillMount` for data loading
* `componentDidMount` used in place of `componentWillMount` for data loading in `firebaseConnect` and `firestoreConnect`
* `getFirebase` no longer part of the API
* `createFirebaseConnect` and `createFirestoreConnect` are no longer part of the API

### Remove createFirebaseConnect and createFirestoreConnect

These are no longer needed since the extended firebase instance is now loaded through react context instead of through `store.firebase`.

```diff
- const firebaseConnect = createFirebaseConnect('otherStoreKey')
- const firestoreConnect = createFirestoreConnect('otherStoreKey')
```

### Remove Store Enhancer

Expand Down

0 comments on commit e8e93b8

Please sign in to comment.