这是indexloc提供的服务,不要输入任何密码
Skip to content

Add support for Cloud Functions for Firebase #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 8, 2021
Merged

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