React Native call a function only once

I'm developing an application using react native in this application I have this function called addDetails() this function is executed inside the functionCombined() with another function When the user press the button. In this application the functionCombined() function will be executed according to each button press. But I want to execute the addDetails() function only once, but the uploadPrices() function should be executed according to the button press. Is there any way to implement it?

Basically what I want is to execute the addDetails() function only once that is inside the functionCombined() function. The addDetails() function should be executed on the first button click only after that addDetails() function cannot be executed no matter how many times the user clicks the button. Is there any way to implement it?

const functionCombined = () => {
            addDetails(); 
            uploadPrices();  
        }  



const addDetails = () => {
              
            db.transaction(txn => {
                txn.executeSql(
                    `INSERT INTO invoices (name, date) VALUES (? , ?)`,
                    [customerName,text],
                    (sqlTxn, res) => {
                        console.log(`${customerName}, ${text} added successfully `); 
                        
                    }, 
                    error => {
                        console.log('error on adding details ' + error.message);
                    },
                );
            });
    
            alert("Successfully Upload Customer Details"); 
              
        };


    
    <Pressable onPress={functionCombined}>

Solution 1:

Maybe you can just have a flag, to check if the button was clicked, and add the addDetails() inside the flag check, something like:

const [buttonClicked, setButtonClicked] = useState(false);

const functionCombined = () => {
      if(!buttonClicked){
          addDetails();
          setButtonClicked(true);
       }
      uploadPrices();  
}