【问题标题】:Autolink not working on react-native 0.63.4 and react-native-localize自动链接不适用于 react-native 0.63.4 和 react-native-localize
【发布时间】:2021-02-12 19:05:25
【问题描述】:

我正在学习国际化如何在 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.js reactjs react-native localization


    【解决方案1】:

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

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

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

    【讨论】:

    • 也可以使用 react-native run-android 。谢谢!
    【解决方案2】:

    使用

    npx react-native link react-native-localize
    

    而不是

    react-native link react-native-localize
    

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-21
      • 1970-01-01
      • 1970-01-01
      • 2020-05-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多