yarn add react-native-config
react-native link react-native-config
- Create
.env
files for each configuration. Ex:.env.dev
,.env.prod
, etc Ex:
API_ENDPOINT=https://api.myresource.com/dev
ENV=dev
name: Detox | |
on: [push] | |
jobs: | |
build: | |
runs-on: macOS-latest | |
timeout-minutes: 15 | |
env: |
// Since ES6 Map()'s' retain their order of insertion, it can sometimes be useful to get the last item or value inserted: | |
export const getLastItemInMap = map => Array.from(map)[map.size-1] | |
export const getLastKeyInMap = map => Array.from(map)[map.size-1][0] | |
export const getLastValueInMap = map => Array.from(map)[map.size-1][1] | |
// Obviously getLastKey and getLastValue can reuse getLastItem, but for maximum portability I opted for verbosity. |
yarn add react-native-config
react-native link react-native-config
.env
files for each configuration. Ex: .env.dev
, .env.prod
, etc
Ex:API_ENDPOINT=https://api.myresource.com/dev
ENV=dev
regex valid update
const validEmail(str) => !/(\.{2}|-{2}|_{2})/.test(val) && /^[a-z0-9][a-z0-9-_\.]+@[a-z0-9]+([a-z0-9-])?[a-z0-9]\.[a-z]{2,10}(?:\.[a-z]{2,10})?$/.test(val);
validEmail('admin@gmail.com'); //true
validEmail('.admin@gmail.com'); //false
validEmail('admin--admin@gmail.com'); //false
validEmail('admin@-myapp-.com'); //false
validEmail('admin@my-large-domain.news'); //valid
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
NSURL *jsCodeLocation; | |
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; | |
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation | |
moduleName:@"Reservio" | |
initialProperties:nil | |
launchOptions:launchOptions]; |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// 1. init window | |
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; | |
UIViewController *rootViewController = [UIViewController new]; | |
// 2. backgroundView using LaunchScreen.xib | |
UIView *backgroundView = [[[NSBundle mainBundle] loadNibNamed:@"LaunchScreen" owner:self options:nil] firstObject]; | |
backgroundView.frame = self.window.bounds; | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
... | |
... | |
... | |
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation | |
moduleName:@"MyAwesomeApp" | |
initialProperties:@{} | |
launchOptions:launchOptions]; |
A Pen by Jan Ziemba on CodePen.