React Native IOS release build js tree shaking

87 Views Asked by At

I have following js code in my react native project

import ...;

const {PLATFORM} = Config;
if(PLATFORM === 'APN'){

   async function onAppleLogin(callback = ()=>{}){
       // some logic here
   }
}

class LoginPage extends React.Component{

   onAppleBtnPres = () => {
       console.log(typeof onAppleLogin); // <-------- issue on here

       if(typeof onAppleLogin !== function){
          // some logic here
          return false
       }

       onAppleLogin(()=>{
          // some logic here
       })
   }

   render(){
      return (
         <Button 
             onPress={this.onAppleBtnPres} 
             title = "Apple Sign In"
         />
   }
}

In debugger, "typeof onAppleLogin" produce difference value in ios release/debug configurations.

Conditions below had been examinated

  1. typeof onAppleLogin -> undefined // release configurations
  2. typeof onAppleLogin -> [function] // debug configurations

My RN ios run properly with debug configuration, but issue comes up when using release configuration (onAppleLogin function always undefined).

I'm using RN version 0.64 and I leave all ios configuration settings default except signing and capabilities.

0

There are 0 best solutions below