在 React Native 中,有一些第三方组件可以编译自己的库,这些库可以包含在您的主 React 项目中。此类第三方库的示例如下:
- https://github.com/naoufal/react-native-touch-id https://github.com/naoufal/react-native-touch-id
- https://github.com/lazaronixon/react-native-qrcode-reader https://github.com/lazaronixon/react-native-qrcode-reader
- https://github.com/brentvatne/react-native-modal https://github.com/brentvatne/react-native-modal
现在,我非常想使用链接库创建自己的 React Native 组件(仅限 iOS,所以我只需要使用此方法链接的 Cocoa 库:https://facebook.github.io/react-native/docs/linking-libraries-ios.html https://facebook.github.io/react-native/docs/linking-libraries-ios.html),到目前为止,我发现的是:http://moduscreate.com/react_native_custom_components_ios/ http://moduscreate.com/react_native_custom_components_ios/
但是,生成的项目未指定库目标,并且不可链接到其他项目。
我还尝试过复制 Touch ID 存储库并尝试更改该代码,但可惜的是,我发现如果不从其他项目引用它就无法编译,而该项目又将是要编译的项目。
我在哪里可以找到有关如何执行此操作的指南?谢谢!
1.命令:new-library
React-native-cli 提供了新图书馆 https://github.com/facebook/react-native/blob/master/local-cli/library/library.js#L64命令:
react-native new-library --name <YourNewLibraryName>
调用此函数将在您的中生成一个示例库Libraries
通过从以下目录复制示例文件反应本机库 https://github.com/facebook/react-native/tree/master/Libraries/Sample.
2. 开发
React Native 有几个专门用于编写的文档本机模块 http://facebook.github.io/react-native/docs/native-modules-ios.html#content and 本机 UI 组件 http://facebook.github.io/react-native/docs/native-components-ios.html#content,取决于您想要实现的目标。
3.链接组件
完成后,按照以下链接链接您的组件指示 http://facebook.github.io/react-native/docs/linking-libraries-ios.html#content你已经提到过。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)