'HeaderConfig'的React-native渲染方法

tuwxkamq  于 2023-06-06  发布在  React
关注(0)|答案(1)|浏览(158)

我收到一个错误,它指向react-native组件中的依赖项问题,但我找不到提到如何解决这个问题的帖子。它指出错误在'react-jsx-runtime.development.js'中
元素类型无效:需要字符串(对于内置组件)或类/函数(对于复合组件),但得到:您可能忘记了从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。检查“HeaderConfig”的呈现方法。
下面是我的index.js:

import { useState } from 'react'
// react-native components 
import { Text, View, ScrollView, SafeAreaView } from 'react-native'
// like react router
import { Stack, useRouter } from 'expo-router'

// import contants to style 
import { COLORS, icons, images, SIZES } from '../constants'

// import components. cmd+click to confirm scope 
import { Nearbyjobs, Popularjobs, ScreenHeaderBTN, Welcome } from '../components'

// const home = functional component where we can return view with text inside
const Home = () => {
    const router = useRouter();
        return (
            <SafeAreaView style={{ flex: 1, backgroundColor: COLORS.lightWhite }}>
                <Stack.Screen
                    options={{
                        headerStyle: { backgroundColor: COLORS.lightWhite },
                        headerShadowVisible: false,
                        headerLeft: () => (
                            <ScreenHeaderBTN iconUrl={icons.menu} dimension='60%' />
                        ),
                        headerRight: () => (
                            <ScreenHeaderBTN iconUrl={icons.profile} dimension='100%' />
                        )
                    }}
                />
            </SafeAreaView>
        )
}

export default Home;
mkshixfv

mkshixfv1#

该文件实际上被命名为ScreenHeaderBtn,我错误地导入了'ScreenHeaderBTN'。ScreenHeaderBtn解决了这个问题。

相关问题