Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

how to use both ios and android libs in the same entry file #19

Closed
julesbou opened this issue Mar 30, 2016 · 4 comments
Closed

how to use both ios and android libs in the same entry file #19

julesbou opened this issue Mar 30, 2016 · 4 comments

Comments

@julesbou
Copy link

I have an application where the entry file is index.js (i.e. i'm not using index.android.js nor index.ios.js).

I'm a bit surprised about the choice to split your library into two projects react-native-lock-ios and react-native-lock-android, this decision seems to be more developer friendly than user friendly.

That being said, how can I import both libraries in my index.js file? I tried many things like:

if (Platform === 'ios') {
  import Auth0Lock from 'react-native-lock-ios';
} else {
  import Auth0Lock from 'react-native-lock-android';
}

(which of course doesn't work because es6 does not allows dynamic import/export.)

@julesbou julesbou changed the title how to use both ios and android libs in the same file how to use both ios and android libs in the same entry file Mar 30, 2016
@fforres
Copy link

fforres commented Mar 30, 2016

How about you go with the old-school require()

@cancan101
Copy link

Why not add another js file that just does the imports and have one version of that for android and one for ios and then export Auth0Lock from that file.

@fforres
Copy link

fforres commented Apr 1, 2016

You fixed it @julesbou
Would be cool to leave your thoughts in case someone else is asking the same :)

@julesbou
Copy link
Author

julesbou commented Apr 1, 2016

Both of your solutions are better I guess.

I created two entry files (one for ios, one for android) and exported Auth0Lock globally:

// index.ios.js
global.Auth0Lock = require('react-native-lock-ios');
import {} from './index.js';

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants