React Native In My Real World


React Native was introduced in January of 2015 at React.js Con: The first public preview. In March of 2015, React Native is open and available on Github. After releasing, React Native quickly becomes popular and is constantly updated by thousands of developers in the world. Currently, React Native is one of the most stars repositories on Github.

Threads

Performance

Native modules

1
2
3
$ react-native run-ios --simulator 'iPad Pro (9.7 inch)'
$ react-native run-ios --device 'qa'
$ react-native run-ios --configuration Release --device 'qa'
1
2
3
4
5
6
7
8
9
#import <React/RCTBridgeModule.h>
@interface RCT_EXTERN_MODULE(SDKWrapper, NSObject)
RCT_EXTERN_METHOD(supportedEvents)
RCT_EXTERN_METHOD(startScanning)
RCT_EXTERN_METHOD(stopScanning)
RCT_EXTERN_METHOD(playAnimation)
RCT_EXTERN_METHOD(connectToDevice:(NSString *)serialNumber:(RCTPromiseResolveBlock)resolve:(RCTPromiseRejectBlock)reject) //Promise
RCT_EXTERN_METHOD(disConnectToDevice:(RCTPromiseResolveBlock)resolve:(RCTPromiseRejectBlock)reject) //Promise
@end
1
2
3
4
5
6
7
8
9
10
11
12
public class SDKWrapper extends ReactContextBaseJavaModule 
{
public SDKWrapper(ReactApplicationContext reactContext)
{
super(reactContext);
}
@Override public String getName()
{
return "SDKWrapper";
}
@ReactMethod public void startScanning() {. . .}
}
1
2
3
4
5
6
import {NativeModules} from 'react-native'; 
const {SDKWrapper} = NativeModules;
....
SDKWrapper.doSomething();
SDKWrapper.saySomething();
....

Pros and cons

Pros

  • Native performance

  • Learn once, run everywhere

  • Flex box

  • Hot reloading

  • Platform detection in code

Cons

  • Not stable, hard to keep up

  • Lack of documentation

  • Single dedicated device thread

  • Calling callback

Conclusion

Comments