TypeError:未定义不是对象(评估' theme.pacing [radius]')
我正在使用React本地元素库来构建UI。我正在尝试使用图标创建一个按钮。最初,我只是从网站复制了此代码,而没有任何更改以查看按钮是否有效。
import { Button } from "@rneui/themed";
<Button
title="Basic Button"
buttonStyle={{
backgroundColor: 'rgba(78, 116, 289, 1)',
borderRadius: 3,
}}
containerStyle={{
width: 200,
marginHorizontal: 50,
marginVertical: 10,
}}
/>
我一直在应用程序中遇到此错误
TypeError: undefined is not an object (evaluating 'theme.spacing[radius]')
来自ui.library随附的内部按钮。我不确定会导致这一点。我设法使用了库中的输入组件而没有任何问题,因此我认为我已经正确安装了它。那可能导致此按钮问题是什么呢?
I am using react native elements library to build a UI. I am trying to create a button with an icon. I initially just copied this code from the website without any changes to see if the button works.
import { Button } from "@rneui/themed";
<Button
title="Basic Button"
buttonStyle={{
backgroundColor: 'rgba(78, 116, 289, 1)',
borderRadius: 3,
}}
containerStyle={{
width: 200,
marginHorizontal: 50,
marginVertical: 10,
}}
/>
I keep getting this error in the app
TypeError: undefined is not an object (evaluating 'theme.spacing[radius]')
which comes from inside Button.js that comes with the ui.library. I am not sure what could be causing this. I managed to use the input component from the library without any issues and from that I would assume I installed it properly. What could be causing this button problem then?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
导入
按钮
来自@rneui/base
而不是@rneui/主题
的模块Import
Button
module from@rneui/base
instead of@rneui/themed
为什么您不使用触摸和图标创建按钮
它比您使用库更容易
why you don't create button with touchOpacity and icon
it easier than you use library
我也有这个问题。您可以通过将 themeprovider 组成组件中的react-native-elements(@rneui)包装在您的应用程序的根源中来解决此问题。例如;
官方迁移指南反应元素:
https://reaectnativeelements.com/docs/docs/migration_guide
I had this issue too. You can solve this issue by wrapping the ThemeProvider component from react-native-elements (@rneui) in the root of your app. For example;
official migration guide for react-native-elements:
https://reactnativeelements.com/docs/migration_guide