Aditya Sutar
Aditya Sutar

Reputation: 75

NextJS Element type is invalid

I create one component in the widget folder and import it into my main homepage (index.js)

It showing error

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.

The main file code is

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 {}

Upvotes: 0

Views: 575

Answers (1)

baldman
baldman

Reputation: 25

You have to import React like this:

import React, { Component } from "react";

The first one is a default import, the second is a named import.

Upvotes: 1

Related Questions