Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions docs/recipes/profile.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ Profile object is used to store data associated with a user. Using profile is in

It is common to store the list of user profiles under a collection called "users" or "profiles". For this example we will use "users".

Include the `userProfile` parameter in config when setting up store enhancer:
Include the `userProfile` parameter in config passed to react-redux-firebase:

```js
const config = {
userProfile: 'users', // where profiles are stored in database
}
```

### Using useSelector Hook
### Get Profile From State

#### Using useSelector Hook

Then later `connect` (from [react-redux](https://github.com/reactjs/react-redux/blob/master/docs/api.md)) to redux state with:

Expand All @@ -32,7 +34,7 @@ function SomeComponent() {
}
```

### Using connect HOC
#### Using connect HOC

Then later `connect` (from [react-redux](https://github.com/reactjs/react-redux/blob/master/docs/api.md)) to redux state with:

Expand All @@ -52,6 +54,17 @@ connect(
connect(({ firebase: { profile } }) => ({ profile }))(SomeComponent)
```

## Profile in Firestore

To use Firestore for storing profile data instead of Real Time Database, the basic example can be followed exactly with the following config.

```js
const config = {
userProfile: 'users', // where profiles are stored in database
useFirestoreForProfile: true // use Firestore for profile instead of RTDB
}
```

## Update Profile

The current users profile can be updated by using the `updateProfile` method:
Expand Down Expand Up @@ -109,11 +122,14 @@ const config = {
}
```

This also works with profiles stored on Firestore if using the `useFirestoreForProfile` option

## List Online Users

To list online users and/or track sessions, view the [presence recipe](/docs/recipes/auth.md#presence)

## Populate Parameters

If profile object contains an key or a list of keys as parameters, you can populate those parameters with the matching value from another location on firebase.

#### List
Expand Down
7 changes: 6 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,12 @@ export interface ReduxFirestoreQuerySetting {
* Collection name
* @see https://github.com/prescottprue/redux-firestore#collection
*/
collection: string
collection?: string
/**
* Collection Group name
* @see https://github.com/prescottprue/redux-firestore#collection-group
*/
collectionGroup?: string
/**
* Document id
* @see https://github.com/prescottprue/redux-firestore#document
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "3.1.0",
"version": "3.1.1",
"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