You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Expo.io使用React Native时报错“Super expression must be either null or a function”

报错原因与修复方案

这个错误和你使用的Expo 42.00版本、浏览器版本均无关,是代码语法书写错误导致的。

具体错误点

你在声明App类继承React.Component的语句末尾多写了一对不必要的括号:

// 错误写法
export default class App extends React.Component(){

extends关键字后面需要跟随要继承的父类本身,而你加了括号相当于把React.Component作为普通函数调用后把返回值作为父类,React.Component直接调用的返回值既不是函数也不是null,正好匹配你遇到的报错提示。

修复方案

直接删掉React.Component后面的括号即可,修改后的完整代码如下:

import React from 'react'
import { Text, View, StyleSheet } from 'react-native';

export default class App extends React.Component {
  render(){
    return(
     <View> </View>
    )
  }
}

修改后重新执行启动命令即可解决该报错。

内容的提问来源于stack exchange,提问作者Alex

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 05:18:02