首页 > 解决方案 > 自动链接不适用于 react-native 0.63.4 和 react-native-localize

问题描述

我正在学习国际化如何在 React Native 上发挥作用。为此,我正在使用博览会。我正在使用这个库: https ://github.com/zoontek/react-native-localize

当我在网络浏览器上测试它时,它可以完美运行,但是当我在我的 Android 物理设备上测试它时,它就不起作用了。显然 react-native-localize 的链接不起作用。我收到此错误:

Error: react-native-localize: NativeModule.RNLocalize is null. To fix this issue try these steps:
• Run `react-native link react-native-localize` in the project root.
• Rebuild and re-run the app.
• If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
• Check that the library was linked correctly when you used the link command by running through the manual installation instructions in the README.
• If you are getting this error while unit testing you need to mock the native module. Follow the guide in the README.
• If none of these fix the issue, please open an issue on the Github repository: https://github.com/zoontek/react-native-localize

然后,如果我运行react-native link react-native-localize它会显示一个警告,表明它已被弃用并且它不起作用。

在我的 package.json 上,我有这个版本的依赖本地化和 react-native:

"react-native-localize": "^2.0.1",
"react-native": "~0.63.4",

应该自动完成高于 0.60 的 react-native 链接。

如果需要任何进一步的信息,请告诉我。

标签: node.jsreactjsreact-nativelocalization

解决方案


尝试通过 npx react-native run-android 命令再次运行项目。

如果您使用的是 iOS 设备,则:

cd ios && pod install npx react-native run-ios 如果仍然无法正常工作,请尝试再次安装 npm 包并按照文档进行操作。


推荐阅读