Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

Using React-Native library inside another React-Native library

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...