Table of Contents

useFirestore

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'

export default function AddData({ firebase: { add } }) {
  const firestore = useFirestore()

  function addTodo() {
    const exampleTodo = { done: false, text: 'Sample' }
    return firestore.collection('todos').add(exampleTodo)
  }

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

Returns object Extended Firestore instance

results matching ""

    No results matching ""