REACT Native可以进口组件“不确定不是函数”

发布于 2025-01-21 17:41:32 字数 1555 浏览 2 评论 0原文

我正在尝试将此组件从github导入我的代码:( https://github.com/ bibekg/react-schedule-selector )。但是,当我运行博览会时,它没有注册,并且我会收到此错误: undefined不是函数

这是我的代码:

import ScheduleSelector from "react-schedule-selector/src/lib";

export default function ({ navigation }) {
    const [schedule, setSchedule] = React.useState([]);
    return (
        <Layout>
            <TopNav
                leftContent={<Ionicons name="chevron-back" size={20} color={"black"} />}
                leftAction={() => navigation.navigate("Me")}
                middleContent="Schedule"
            />
            <View
                style={{
                    flex: 1,
                    alignItems: 'center',
                    justifyContent: 'center',
                }}
            >
                <Text>https://github.com/bibekg/react-schedule-selector</Text>
                <ScheduleSelector
                    selection={schedule}
                    numDays={5}
                    minTime={8}
                    maxTime={22}
                    hourlyChunks={2}
                    onChange={(val) => setSchedule(val)}
                />
            </View>
        </Layout>
    );
}

另外,我已经运行npm nplas nplast instal react-我的计算机上的计划选择型组件!

关于为什么发生此错误以及如何解决该错误的任何想法?谢谢!

I am trying to import this component from github into my code: (https://github.com/bibekg/react-schedule-selector). However, it's not registering when I run expo and I get this error:
Undefined is not a function

Here is my code:

import ScheduleSelector from "react-schedule-selector/src/lib";

export default function ({ navigation }) {
    const [schedule, setSchedule] = React.useState([]);
    return (
        <Layout>
            <TopNav
                leftContent={<Ionicons name="chevron-back" size={20} color={"black"} />}
                leftAction={() => navigation.navigate("Me")}
                middleContent="Schedule"
            />
            <View
                style={{
                    flex: 1,
                    alignItems: 'center',
                    justifyContent: 'center',
                }}
            >
                <Text>https://github.com/bibekg/react-schedule-selector</Text>
                <ScheduleSelector
                    selection={schedule}
                    numDays={5}
                    minTime={8}
                    maxTime={22}
                    hourlyChunks={2}
                    onChange={(val) => setSchedule(val)}
                />
            </View>
        </Layout>
    );
}

Also, I have already run npm install react-schedule-selector styled-components on my computer!

Any ideas on why this error is occurring and how to fix it? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

药祭#氼 2025-01-28 17:41:32

该声明

import ScheduleSelector from "react-schedule-selector/src/lib";

不正确。您需要将其更改为以下内容。

import ScheduleSelector from 'react-schedule-selector'

这记录在此处

The statement

import ScheduleSelector from "react-schedule-selector/src/lib";

is not correct. You need to change it to the following.

import ScheduleSelector from 'react-schedule-selector'

This is documented here.

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