我在widget文件夹中创建了一个组件,并将其导入到我的主主页(index.js)
显示错误
Error: Element type is invalid: expected a string (for built-in components) or 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.
主文件代码
import { React, Component } from "react";
import axios from "axios";
import Style from "./widget-style/Notified.module.css";
import NotifiedModal from "../modals/NotifiedModal";
export default class GetNotified extends Component {}
你必须像这样导入React:
import React, { Component } from "react";
第一个是默认导入,第二个是命名导入。