React-native : detect dev or production env

前端 未结 1 729
旧巷少年郎
旧巷少年郎 2020-12-14 00:40

I develop a react-native app where some API calls should be made.

If I\'m in production mode my app should call, for example, this host :

https://exa         


        
1条回答
  •  醉梦人生
    2020-12-14 01:12

    Set automatically

    The constant __DEV__ is set automatically.

    Production

    Building the bundle via --dev=false should unset __DEV__.

    Usage

    if (__DEV__) {
        console.log('Development');
    } else {
        console.log('Production');
    }
    

    0 讨论(0)
提交回复
热议问题