简体   繁体   English

元素类型无效:检查提供者的渲染方法(React Native)

[英]Element type is invalid: Check render method of Providers (React Native)

im working for a school project with react to create an app.我正在为一个学校项目工作,反应是创建一个应用程序。 But currently im facing a problem with this error.但目前我面临这个错误的问题。 I cant tell you why this is happening.我不能告诉你为什么会这样。 Its a part for a Firebase Auth Login.它是 Firebase 身份验证登录的一部分。

× Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. × 错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义。 You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.您可能忘记从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。

Check the render method of Providers .检查Providers的渲染方法。

× ×

App.js应用程序.js

import React from 'react';
import { render } from 'react-dom';
import Providers from './navigation';
 
const App = () => {
  return(
    <Providers />

  )
}
 
export default App;

Here is the Provider Function这是提供者功能

import React from 'react';
import AuthProvider from './AuthProvider';
import Routes from './Routes';

const Providers = () => {
  return (
    <AuthProvider>
      <Routes />
    </AuthProvider>
  );
}

export default Providers;

This is my AuthProvider这是我的 AuthProvider

import React, {createContext, useState} from 'react';
import auth from '@react-native-firebase/auth';

export const AuthContext = createContext();

export const AuthProvider = ({children}) => {
    const [user, setUser] = useState(null);
  
    return (
      <AuthContext.Provider
        value={{
          user,
          setUser,
          login: async (email, password) => {
            try {
              await auth().signInWithEmailAndPassword(email, password);
            } catch (e) {
              console.log(e);
            }
          },
          register: async (email, password) => {
            try {
              await auth().createUserWithEmailAndPassword(email, password);
            } catch (e) {
              console.log(e);
            }
          },
          logout: async () => {
            try {
              await auth().signOut();
            } catch (e) {
              console.log(e);
            }
          },
        }}>
        {children}
      </AuthContext.Provider>
    );

    
  };

You are exporting AuthProvider as a named export您将AuthProvider作为命名导出导出

try like this import {AuthProvider} from './AuthProvider';尝试像这样import {AuthProvider} from './AuthProvider';

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 React Native Element Type无效。 选中渲染方法 - React Native Element Type is Invalid. Check Render Method 错误:元素类型无效,检查 React Native 中的渲染方法 - Error: Element type is invalid with Check the render method in React Native React-Native 错误:元素类型无效 ()。 检查`Details`的渲染方法 - React-Native Error: Element type is invalid(). Check the render method of `Details` 在 React Native App 中,我得到了错误:元素类型无效:期望一个字符串(对于内置组件)...检查 `App` 的渲染方法? - In React Native App, I Got the Error: Element type is invalid: expected a string (for built-in components) ... Check the render method of `App`? ReactJs元素类型无效检查render方法 - ReactJs Element type is invalid Check the render method 元素类型无效:检查渲染方法 - Element type is invalid: check the render method 不变违规:元素类型在 createMaterialTopTabNavigator()/MaterialTopTabView 渲染方法中无效,React Native w/React Navigation v5 - Invariant Violation: Element type is invalid in createMaterialTopTabNavigator()/MaterialTopTabView render method, React Native w/ React Navigation v5 组件异常:元素类型无效,请检查应用程序的渲染方法 - Component Exception: Element Type is Invalid, check render Method of app 错误:元素类型无效,检查相机的渲染方法 - Error: Element type is invalid with Check the render method of Camera 检查`Drawer`的渲染方法。 元素类型无效错误 - Check the render method of `Drawer`. Element type is invalid Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM