Closed jhuleatt closed 3 years ago
function Calculator() { const functions = useFunctions(); const remoteCalculator = httpsCallable(functions, 'calculate'); const [calculationResult, setResult] = useState(null); async function handleButtonClick(firstNumber, secondNumber, operator) { const remoteCalculatorResponse = await remoteCalculator({ firstNumber, secondNumber, operator }); setResult(remoteCalculatorResponse.data); } if (!calculationResult) { return <button onClick={() => handleButtonClick(1, 2, '+')}>Click me to add 1 + 2</button>; } else { return <pre>{calculationResult}</pre>; } }
fixes #330
~Tests are failing because I need to update the workflow yaml to run npm install in the functions directory~
npm install
Tests are passing now!
Code sample
fixes #330