尝试使用@react-native-community/slider 时,在 UI 管理器中找不到 RNCSlider

RNCSlider was not found in the UI Manager when trying to use @react-native-community/slider(尝试使用@react-native-community/slider 时,在 UI 管理器中找不到 RNCSlider)
本文介绍了尝试使用@react-native-community/slider 时,在 UI 管理器中找不到 RNCSlider的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的 react native Android 应用程序中创建一个滑块,并且对于 React Native 来说相对较新.React Native 文档说他们的 Slider 组件已被弃用(https://reactnative.dev/docs/slider.html)并指示我们改用@react-native-community/slider(https://github.com/react-native-community/react-native-slider/blob/master/README.md).

I'm trying to create a slider in my react native Android App, and relatively new to React Native. The React Native documentation says their Slider component is deprecated (https://reactnative.dev/docs/slider.html) and directs us to use @react-native-community/slider instead (https://github.com/react-native-community/react-native-slider/blob/master/README.md).

我使用 npm install @react-native-community/slider --save 在我的项目目录中安装了该库.

I installed the library in my project directory using npm install @react-native-community/slider --save.

安装成功,我的 package.json 中的版本如下:

The install succeeded and my versions in my package.json are as follows:

"dependencies": {
    "@react-native-community/slider": "^3.0.3",
    "react": "16.13.1",
    "react-native": "0.63.0" },

我使用 import Slider from '@react-native-community/slider'; 在我的源文件中包含滑块,但是当我尝试在我的代码中实际创建滑块时<代码><滑块>... </Slider> 标签,我得到以下编译错误:

I am including the Slider in my source file with import Slider from '@react-native-community/slider';, however when ever I try to actually create a slider in my code with the <Slider> ... </Slider> tags, I get the following compile error:

错误不变违规:requireNativeComponent:RNCSlider"在 UIManager 中找不到.

ERROR Invariant Violation: requireNativeComponent: "RNCSlider" was not found in the UIManager.

我一直在用头撞墙,不知道如何清除错误.我在为 Android 开发的 Windows 10 x64 上.提前致谢!

I've been banging my head against the wall and can't figure out how to clear the error. I am on Windows 10 x64 developing for Android. Thanks in advance!

推荐答案

对我来说解决方案是运行npx react-native run-android"在我的项目目录中,而不是尝试使用npx react-native start".我不确定为什么会这样,但它会在另一个控制台窗口(使用 cli.js)而不是在 powershell 本身中启动 Metro 服务器.这似乎解决了问题.

The solution for me was to just run "npx react-native run-android" in my project directory rather than trying to use "npx react-native start". I'm not sure why this works, but it launches the metro server in another console window (using cli.js) rather than in powershell itself. This seems to solve the problem.

从历史上看,我一直直接从我的模拟手机操作系统启动该应用程序,但即使我在 powershell 中运行 Metro 服务器,这也不起作用.

Historically I had been launching the app directly from my emulated phone OS, but this didn't work even if I had the metro server running in powershell.

这篇关于尝试使用@react-native-community/slider 时,在 UI 管理器中找不到 RNCSlider的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)
Android + coreLibraryDesugaring: which Java 11 APIs can I expect to work?(Android+core LibraryDesugering:我可以期待哪些Java 11API能够工作?)
How to render something in an if statement React Native(如何在If语句中呈现某些内容Reaction Native)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Using Firebase Firestore in offline only mode(在仅脱机模式下使用Firebase FiRestore)
Crash on Google Play Pre-Launch Report: java.lang.NoSuchMethodError(Google Play发布前崩溃报告:java.lang.NoSuchMethodError)