Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native import package only on Android

Tags:

react-native

I'm trying to import a package only on Android here is the package anyone has any idea if this is possible?

import {ProcessingManager} from 'react-native-video-processing'; 
like image 686
Almog Avatar asked Oct 09 '17 03:10

Almog


1 Answers

You have two way for this:

First way:

You can separate platform code by creating two different files your_file_name.android.js and your_file_name.ios.js.

For example, you have to have this files in your directory

BigButton.ios.js
BigButton.android.js

You can then require the component as follows:

import BigButton from './BigButton'

reference: react netive

Second way:

I am not sure for this way

var ProcessingManager;

if (Platform.OS == 'android') {
    ProcessingManager = require('react-native-video-processing');
}
like image 137
Mahdi Bashirpour Avatar answered Sep 21 '22 17:09

Mahdi Bashirpour