首页 > 解决方案 > TypeError:- 类扩展值未定义不是构造函数或 null

问题描述

我刚刚开始学习 React。当我通过 node.js 运行服务器时,我在 localhost:3000 中收到此错误

TypeError: Class extends value undefined is not a constructor or null

索引.js

import React , {Compnonent} from "react";

class lottery extends Compnonent {
    render() {
        return (
            <h1>Decentralized Lottery Application</h1>
        )
    }
}

export default lottery;

标签: reactjs

解决方案


有一个错字 {Component} 修复它。

您将其拼写为 {Compnonent}

import React , {Component} from "react";

推荐阅读