Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Calculator

0

73
Views
React Native how to pass function as a parameter

I am getting error that owScene is not a function. I am trying to pass a function as a parameter to another function. The code below is a slim down version of the full code. Basically scene.js will call the alert function. The alert function will show options to save. When a button is press from the alert.js function I am hoping to send the button press back out to the function from scene.js

scene.js

 saveOptions('scene', owScene, handCancel);

 const owScene = () => {
   SaveMidi.overWrite(selections).then(() => {
     navigation.goBack();
   });
 };

const handCancel = () => {
   SaveMidi.overWrite(selections).then(() => {
     navigation.goBack();
   });
 };

alert.js

const buttons = () => {
  let options = [];
  switch (alertType) {
    case "scene":
      options = [
        {
          text: "Cancel",
          onPress: () => handCancel(),
          style: "cancel",
        },
        { text: "Overwrite", onPress: () => owScene() },
      ];
      break;
    case "volume":
      options = [
        {
          text: "Cancel",
          onPress: () => handCancel(),
          style: "cancel",
        },
        { text: "Overwrite", onPress: () => owVolume() },
      ];
      break;

    default:
      break;
  }

  return options;
};

Alert.alert('Midi Mapping Alert', 'Select save option', buttons());
7 months ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post job Plans Our process Sales
Legal
Terms and conditions Privacy policy
© 2023 PeakU Inc. All Rights Reserved.