MCPcopy Index your code
hub / github.com/FirebaseExtended/reactfire / Counter

Function Counter

example/withSuspense/RealtimeDatabase.tsx:10–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { AuthWrapper } from './Auth';
9
10const Counter = () => {
11 const database = useDatabase();
12 const counterRef = ref(database, 'counter');
13 const increment = (amountToIncrement) => {
14 return set(counterRef, rtdbIncrement(amountToIncrement));
15 };
16
17 const response = useDatabaseObjectData(counterRef);
18
19 const { data: count } = response;
20
21 return (
22 <>
23 <button onClick={() => increment(-1)}>-</button>
24 <span> {count as any} </span>
25 <button onClick={() => increment(1)}>+</button>
26 </>
27 );
28};
29
30const AnimalsList = () => {
31 const database = useDatabase();

Callers

nothing calls this directly

Calls 3

useDatabaseFunction · 0.85
useDatabaseObjectDataFunction · 0.85
incrementFunction · 0.70

Tested by

no test coverage detected