preface

RN has only two environments at the beginning. Generally speaking, an APP may have multiple environments for testing or business use, such as Staging environments. The sample code

iOS

New Configurations

Add the APP_ENV macro in the corresponding environment

Bridge constants for use by RN

Switch the environment

You can run the react-native run-ios –configuration “Staging” command

Re-pod install if you encounter library Not found for-lbase64 errors

Android

Build. gradle added releaseStaging

Specific see the react. Gradle

New matchingFallbacks = [‘release’]

This eliminates the need to add releaseStaging internally for third party library use and release environments

Bridge constants for use by RN

Switch the environment

React-native run-android –variant “releaseStaging”

JS

Derived constants

Switch to Staging