react native module

React Native Module

Getting Started

npm install -g react-native-create-library
react-native-create-library -—platforms ios,android NativeToastLibrary

Setting up the Native Files

@ReactMethodpublic void show(String text) {  Context context = getReactApplicationContext();  Toast.makeText(context, text, Toast.LENGTH_LONG).show();}
"devDependencies": {  "react-native": "0.41.2"},

#import “IOSNativeToast.h”@interface RNNativeToastLibrary()@property (nonatomic, retain) IOSNativeToast *toast;@end
- (instancetype)init {  self = [super init];  if (self) {    self.toast = [[IOSNativeToast alloc] init];  }  return self;}
+ (BOOL)requiresMainQueueSetup{  return YES;}
RCT_EXPORT_METHOD(show:(NSString *)text){  [self.toast showToast:text];}

Upload your library to NPM

npm config set registry

Using Toast

include ‘:react-native-native-toast-library-XXXX’project(‘:react-native-native-toast-library-XXXX’).projectDir = new File(rootProject.projectDir, ‘../node_modules/react-native-native-toast-library-XXXX/android’)
compile project(‘:react-native-native-toast-library’)

We are almost done

android and ios

React Apollo vs Redux + REST: Implementing the same feature twice


Wix Engineering

Architecture, scaling, mobile and web development, management and more, written by our very own Wix engineers.

Source by: