Skip to content

Conversation

jhuleatt
Copy link
Collaborator

@jhuleatt jhuleatt commented Sep 3, 2021

Code sample

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

@google-cla google-cla bot added the cla: yes label Sep 3, 2021
@jhuleatt
Copy link
Collaborator Author

jhuleatt commented Sep 7, 2021

Tests are failing because I need to update the workflow yaml to run npm install in the functions directory

Tests are passing now!

Copy link
Contributor

@justjish justjish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jhuleatt jhuleatt merged commit 8596428 into main Sep 8, 2021
@jhuleatt jhuleatt deleted the jhuleatt-functions branch September 8, 2021 21:18
@FirebaseExtended FirebaseExtended locked and limited conversation to collaborators Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preload functions to set region

3 participants