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
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ lib/**
_book/**
_site/**
docs/**
index.d.ts
index.d.ts
examples/**
test/utils.js
45 changes: 28 additions & 17 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module.exports = {
root: true,
parser: 'babel-eslint',
extends: ['standard', 'standard-react', 'prettier', 'prettier/react', 'plugin:jsdoc/recommended'],
plugins: ['babel', 'react', 'prettier', 'react-hooks', 'jsdoc'],
extends: ['standard', 'standard-react', 'prettier', 'prettier/react'],
plugins: ['babel', 'react', 'prettier', 'react-hooks'],
settings: {
react: {
version: 'detect'
Expand All @@ -15,18 +15,29 @@ module.exports = {
rules: {
semi: [2, 'never'],
'no-console': 'error',
'jsdoc/newline-after-description': 0,
'jsdoc/no-undefined-types': [1, { definedTypes: ['React', 'firebase'] }],
'prettier/prettier': ['error', {
singleQuote: true,
trailingComma: 'none',
semi: false,
bracketSpacing: true,
jsxBracketSameLine: true,
printWidth: 80,
tabWidth: 2,
useTabs: false
}]
}
};

'prettier/prettier': [
'error',
{
singleQuote: true,
trailingComma: 'none',
semi: false,
bracketSpacing: true,
jsxBracketSameLine: true,
printWidth: 80,
tabWidth: 2,
useTabs: false
}
]
},
overrides: [
{
files: ['./src/**/**.js'],
plugins: ['jsdoc'],
extends: ['plugin:jsdoc/recommended'],
rules: {
'jsdoc/newline-after-description': 0,
'jsdoc/no-undefined-types': [1, { definedTypes: ['React', 'firebase'] }]
}
}
]
}
2 changes: 1 addition & 1 deletion docs/api/firestoreConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

Higher Order Component that automatically listens/unListens
to provided Cloud Firestore paths using React's Lifecycle hooks. Make sure you
have required/imported Cloud Firestore, including it's reducer, before
have required/imported Cloud Firestore, including its reducer, before
attempting to use. **Note** Populate is not yet supported.

### Parameters
Expand Down
52 changes: 25 additions & 27 deletions docs/api/useFirestoreConnect.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

### Table of Contents

- [useFirestoreConnect][1]
- [Parameters][2]
- [Examples][3]
- [useFirestoreConnect][1]
- [Parameters][2]
- [Examples][3]

## useFirestoreConnect


React hook that automatically listens/unListens
to provided Cloud Firestore paths. Make sure you have required/imported
Cloud Firestore, including it's reducer, before attempting to use.
**Note** Populate is not yet supported.
Populate is supported for Firestore as of v0.6.0 of redux-firestore (added
[as part of issue #48][5]).

### Parameters

- `queriesConfigs` **([object][5] \| [string][6] \| [Array][7] \| [Function][8])** An object, string,
or array of object or string for paths to sync from firestore. Can also be
a function that returns the object, string, or array of object or string.
- `queriesConfigs` **([object][6] \| [string][7] \| [Array][8] \| [Function][9])** An object, string,
or array of object or string for paths to sync from firestore. Can also be
a function that returns the object, string, or array of object or string.

### Examples

Expand All @@ -30,15 +30,17 @@ import { useSelector } from 'react-redux'
import { useFirestoreConnect } from 'react-redux-firebase'

export default function TodosList() {
useFirestoreConnect('todos') // sync todos collection from Firestore into redux
const todos = useSelector(state => state.firestore.data.todos)
useFirestoreConnect(['todos']) // sync todos collection from Firestore into redux
const todos = useSelector((state) => state.firestore.data.todos)
return (
<ul>
{todos &&
todos.map((todo) => (
<li>id: {todo.id} todo: {todo.description}</li>
<li>
id: {todo.id} todo: {todo.description}
</li>
))}
</ul>
</ul>
)
}
```
Expand All @@ -51,10 +53,12 @@ import { useSelector } from 'react-redux'
import { useFirestoreConnect } from 'react-redux-firebase'

export default function TodoItem({ todoId }) {
useFirestoreConnect([{
collection: 'todos',
doc: todoId
}])
useFirestoreConnect([
{
collection: 'todos',
doc: todoId
}
])
const todo = useSelector(
({ firestore: { data } }) => data.todos && data.todos[todoId]
)
Expand All @@ -64,17 +68,11 @@ export default function TodoItem({ todoId }) {
```

[1]: #usefirestoreconnect

[2]: #parameters

[3]: #examples

[4]: https://react-redux-firebase.com/docs/api/useFirestoreConnect.html

[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[5]: https://github.com/prescottprue/redux-firestore/issues/48
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
Loading