Function that creates a hook that which provides
firestore
object.
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 Name of redux store which contains Firestore state (state.firestore
) (optional, default'store'
)
Examples
Basic
import { createUseFirestore } from 'react-redux-firebase'
// create useFirestore that uses another redux store
const useFirestore = createUseFirestore()
// use the useFirestore to wrap a component
export default useFirestore(SomeComponent)
Returns Function Higher Order Component which accepts an array of watchers config and wraps a React Component
Extends React.Component
React hook that return firestore object.
Firestore instance is gathered from store.firestore
, which is attached
to store by the store enhancer (reduxFirestore
) during setup of
redux-firestore
Examples
Basic
import React from 'react'
import { useFirestore } from 'react-redux-firebase'
function AddData({ firebase: { add } }) {
const firestore = useFirestore()
const add = todo => {
firestore.collection('todos').add(todo)
}
return (
<div>
<button onClick={() => add({ done: false, text: 'Sample' })}>
Add Sample Todo
</button>
</div>
)
}
export default AddTodo
Returns Object Firestore instance