0

I created a React-Native application Then I created a React-Native Library using this seed github.com/frostney/react-native-create-library

Now, I need to use this package https://github.com/toystars/react-native-geo-fence Inside of the Library.

Problem is: The library is not a react-native application, and the geo-fence lib needs linking.

I cant change the React-Native App and can not use the geo-fence directly inside of it, of course.

The logic will need to stay inside the Library i created.

When i linked the Library i created (with the geo fence package on it already), with the App i created, the geo-fence gradle settings and android configurations didn't happen at the APP.

  • this concerns Android only
Guilherme Ferreira
  • 2,209
  • 21
  • 23
  • if linking need you can create module like this way (https://github.com/frostney/react-native-create-library) and publish on npm or your local or just github and add package to your package.json – Nazır Dogan Jan 16 '19 at 14:49
  • i created the library using this seed and i need to add a package to it now, point is that this seed is not a react-native app, it cant link anything from inside of it. – Guilherme Ferreira Jan 16 '19 at 14:53
  • I m not sure. I understand you correctly you. but you can install npm module with local path and link package to your project. – Nazır Dogan Jan 16 '19 at 14:57
  • I need to link a library to another library. A library can be only linked to a react-native app project. Which a library is not. That seed is not a react-native app project, so it cant link anything. My APP uses a LIB and this LIB uses, now another LIB that requires linking. But i cant link it because its inside another LIB, not an APP – Guilherme Ferreira Jan 16 '19 at 15:04
  • you can extend library for your need. and you can add as dependency. – Nazır Dogan Jan 16 '19 at 15:06
  • It is added as dependency. But i can't LINK the dependency because the lib is no application. There is no react-native installed at it as it is not a react-native project. React-native is set as peerDependency at package.json. – Guilherme Ferreira Jan 16 '19 at 15:11
  • I also developing native modules. when I developing I m creating test app and link to package to app and after that I can access react-native specific bridge libraries. – Nazır Dogan Jan 16 '19 at 15:13

1 Answers1

4

It is not possible to link a react-native library to another react-native library.

So the correct procedure is to add any third party react-native library, that requires link, that you want to use inside your own react-native library, as peerDependency on package.json.

This way the third party lib will be installed directly at the app, and will be linked, necessarily to the app, but the logic using the third party lib will be inside your own.

So you can create a lib, add react-native-geo-fence as peerDependency of your lib, then code as you wish. After this, the app using your lib, will have to install it and link manually the react-native-geo-fence, then that's it.

Guilherme Ferreira
  • 2,209
  • 21
  • 23