gpt4 book ai didi

react-native - 您可以将具有 native 依赖项的库添加到 Expo react native 项目吗?

转载 作者:行者123 更新时间:2023-12-04 04:51:52 28 4
gpt4 key购买 nike

你可以使用像 https://github.com/tolu360/react-native-google-places 这样的库吗?在世博项目中?我假设任何 npm 库都可以添加,但是像这个 google 位置选择器这样的库需要安装后步骤来链接 native 项目。世博会支持他们吗?

最佳答案

常规 Expo 项目仅用 JavaScript 编写,不支持包含 Objective-C 或 Java 的 npm 包。但是,当您绝对需要使用自定义 native 代码时,Expo 提供了一个名为 ExpoKit 的高级 SDK。来自世博会文档:

Normally, Expo apps are written in pure JS and never “drop down” to the native iOS or Android layer. This is core to the Expo philosophy and it’s part of what makes Expo fast and powerful to use.

However, there are some cases where advanced developers need native capabilities outside of what Expo offers out-of-the-box. The most common situation is when a project requires a specific Native Module which is not supported by React Native Core or the Expo SDK.



您可以“分离”您的 Expo 项目以创建包含 ExpoKit 的 Xcode 和 Android Studio 项目。然后,您可以像添加任何其他 Xcode 或 Android Studio 项目一样添加自定义的 Objective-C 或 Java。

然而,Expo 文档也警告了编写自定义 native 代码的一些缺点;许多功能通常可以在 JS 中很好地实现,让您保留标准 Expo 项目的所有好处。

Warning: We discourage most of our developers from taking this route, as we believe almost everything you need to do is better accomplished in a cross-platform way with JS.

Writing in JS enables you to best take advantage of over-the-air code deployment and benefit from ongoing updates and support from Expo. You should only do this if you have a particular demand from native code which Expo won’t do a good job supporting, such as (for example) specialized CPU-intensive video processing that must happen locally on the device.

关于react-native - 您可以将具有 native 依赖项的库添加到 Expo react native 项目吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41597414/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com