【发布时间】:2020-12-15 12:37:21
【问题描述】:
我在 index.js 中有一个问题,看起来我在导出和导入方面有错误,我检查了我的代码,但找不到错误。请问有什么帮助吗?
我收到此错误:
错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。您可能忘记从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。
查看SelectProfileContainer的渲染方法
我的反应代码(index.js):
import React from "react";
import { render } from "react-dom";
import "normalize.css";
import App from "./app";
import { GlobalStyles } from "./global-styles";
import { firebase } from "./lib/firebase.prod";
import { FirebaseContext } from "./context/firebase";
render(
<>
<FirebaseContext.Provider value={{ firebase }}>
<GlobalStyles />
<App />
</FirebaseContext.Provider>
</>,
document.getElementById("root")
);
这里是 GlobalStyles.js 代码:
import { createGlobalStyle } from "styled-components";
export const GlobalStyles = createGlobalStyle`
html, body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background-color: black;
color: #333333;
font-size: 16px;
}
这是给浏览器的:
检查
SelectProfileContainer的渲染方法。▶ 23 个堆栈帧被折叠。
模块。
C:/Users/CPU-MAJD/OneDrive/Desktop/Completely_fully_Netflix-clone/netflix/src/index.js:9
6 |从“./lib/firebase.prod”导入{ firebase};
7 |从“./context/firebase”导入{ FirebaseContext };
8 |
> 9 |渲染(
10 |
11 |
12 |
【问题讨论】:
-
那么,你检查
SelectProfileContainer的渲染方法了吗? -
我找不到组件
SelectProfileContainer。这个函数不是我创建的 -
你可以在这里查看我的代码github.com/Gloryyy/Netflix-clone-from-scratch