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

Function UpperCaser

example/withoutSuspense/Functions.tsx:10–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8import { getFunctions, httpsCallable } from 'firebase/functions';
9
10function UpperCaser() {
11 const functions = useFunctions();
12 const capitalizeTextRemoteFunction = httpsCallable<{ text: string }, string>(functions, 'capitalizeText');
13 const [uppercasedText, setText] = useState<string>('');
14 const [isUppercasing, setIsUppercasing] = useState<boolean>(false);
15
16 const greetings = ['Hello World', 'yo', `what's up?`];
17 const textToUppercase = greetings[Math.floor(Math.random() * greetings.length)];
18
19 async function handleButtonClick() {
20 setIsUppercasing(true);
21
22 const { data: capitalizedText } = await capitalizeTextRemoteFunction({ text: textToUppercase });
23 setText(capitalizedText);
24
25 setIsUppercasing(false);
26 }
27
28 return (
29 <>
30 <WideButton label="Uppercase some text" onClick={handleButtonClick} />
31 {isUppercasing ? <LoadingSpinner /> : <span>{uppercasedText || `click the button to capitalize "${textToUppercase}"`}</span>}
32 </>
33 );
34}
35
36function UpperCaserOnRender() {
37 const greetings = ['Hello World', 'yo', `what's up?`];

Callers

nothing calls this directly

Calls 1

useFunctionsFunction · 0.85

Tested by

no test coverage detected