TypeError:未定义不是对象(评估' theme.pacing [radius]')

发布于 2025-01-28 09:37:36 字数 838 浏览 6 评论 0原文

我正在使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薄荷港 2025-02-04 09:37:36

导入按钮来自@rneui/base而不是@rneui/主题的模块

Import Button module from @rneui/base instead of @rneui/themed

仅冇旳回忆 2025-02-04 09:37:36

为什么您不使用触摸和图标创建按钮
它比您使用库更容易

why you don't create button with touchOpacity and icon
it easier than you use library

南街九尾狐 2025-02-04 09:37:36

我也有这个问题。您可以通过将 themeprovider 组成组件中的react-native-elements(@rneui)包装在您的应用程序的根源中来解决此问题。例如;

<ThemeProvider theme={myTheme}>
  <Button title="My Button" />
</ThemeProvider>

官方迁移指南反应元素:
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;

<ThemeProvider theme={myTheme}>
  <Button title="My Button" />
</ThemeProvider>

official migration guide for react-native-elements:
https://reactnativeelements.com/docs/migration_guide

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文