()
| 9 | import { getFirestore } from 'firebase/firestore'; |
| 10 | |
| 11 | const Counter = () => { |
| 12 | const firestore = useFirestore(); |
| 13 | const ref = doc(firestore, 'count', 'counter'); |
| 14 | const { status, data: count } = useFirestoreDocData(ref); |
| 15 | |
| 16 | const incrementCounter = (amountToIncrement) => { |
| 17 | updateDoc(ref, { |
| 18 | value: increment(amountToIncrement), |
| 19 | }); |
| 20 | }; |
| 21 | |
| 22 | if (status === 'loading') { |
| 23 | return <LoadingSpinner />; |
| 24 | } |
| 25 | |
| 26 | return ( |
| 27 | <> |
| 28 | <button onClick={() => incrementCounter(-1)}>-</button> |
| 29 | <span> {(count as any).value} </span> |
| 30 | <button onClick={() => incrementCounter(1)}>+</button> |
| 31 | </> |
| 32 | ); |
| 33 | }; |
| 34 | |
| 35 | const AnimalsList = () => { |
| 36 | const firestore = useFirestore(); |
nothing calls this directly
no test coverage detected