Can i get functionality of Electrode native from any other library

380 Views Asked by At

I have created an app on react native. There are only 2 activities in it, now I want to integrate them in my existing android app (Native android app).

I came to know that at the core React-native does not provide the functionality of generating .arr files or native code. For that we need to use Electrode Native.

My Question is: Is there any other way of generating native (iOS/android) code from react-native code? Do any other tool exist? If they do, what other features Electrode native offers to make one consider it?

2

There are 2 best solutions below

0
On BEST ANSWER

React Native provides a module that detects the platform in which the app is running. You can use the detection logic to implement platform-specific code. Use this option when only small parts of a component are platform-specific.

import {Platform, StyleSheet} from 'react-native';

const styles = StyleSheet.create({
  height: Platform.OS === 'ios' ? 200 : 100,
});

Platform.OS will be ios when running on iOS and android when running on Android.

There is also a Platform.select method available, that given an object containing Platform.OS as keys, returns the value for the platform you are currently running on.

import {Platform, StyleSheet} from 'react-native';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    ...Platform.select({
      ios: {
        backgroundColor: 'red',
      },
      android: {
        backgroundColor: 'blue',
      },
    }),
  },
});

This will result in a container having flex: 1 on both platforms, a red background color on iOS, and a blue background color on Android.

Since it accepts any value, you can also use it to return platform specific component, like below:

const Component = Platform.select({
  ios: () => require('ComponentIOS'),
  android: () => require('ComponentAndroid'),
})();

<Component />;

Detecting the Android version On Android, the Platform module can also be used to detect the version of the Android Platform in which the app is running:

import {Platform} from 'react-native';

if (Platform.Version === 25) {
  console.log('Running on Nougat!');
}

Detecting the iOS version On iOS, the Version is a result of -[UIDevice systemVersion], which is a string with the current version of the operating system. An example of the system version is "10.3". For example, to detect the major version number on iOS:

import {Platform} from 'react-native';

const majorVersionIOS = parseInt(Platform.Version, 10);
if (majorVersionIOS <= 9) {
  console.log('Work around a change in behavior');
}

1
On

To answer the question on what other features Electrode native offers to make one consider it?

When developing, integrating, and reusing multiple and distinct React Native components into an existing mobile application, developers face clear challenges.

Electrode Native takes on those challenges by providing an open source platform that reduces the friction for both React Native developers and mobile app developers. Using the Electrode Native platform solution, developers can leverage their knowledge without having to drastically change their workflow to accommodate the integration of multiple React Native components in their mobile application(s)

Electrode Native allows Mobile application developers to easily integrate individual React Native components within their existing mobile application--without changes to their infrastructure or the need to deal with or install any JavaScript based tools--not even Electrode Native itself!

The bottom line: Using Electrode Native, developers can concentrate on functionality and building their apps--without the hassles of reuse or integration issues.

Read more about Why electrode native here.