Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs React App uncaught类型错误:在没有';的情况下无法调用类构造函数App;新';_Reactjs - Fatal编程技术网

Reactjs React App uncaught类型错误:在没有';的情况下无法调用类构造函数App;新';

Reactjs React App uncaught类型错误:在没有';的情况下无法调用类构造函数App;新';,reactjs,Reactjs,这个应用程序代码中有错误吗? 但是VS代码没有突出显示错误 import React, { Component } from 'react'; export default class App extends Component{ render(){ return( <div> <h1>Hello, world! App JS</h1> <h2>It is {new Date(

这个应用程序代码中有错误吗? 但是VS代码没有突出显示错误

import React, { Component } from 'react';
export default class App extends Component{
    render(){
        return(
        <div>
        <h1>Hello, world! App JS</h1>
        <h2>It is {new Date().toLocaleTimeString()}</h2>
        </div>
        );
    }
}
setInterval(App, 1000);
import React,{Component}来自'React';
导出默认类应用程序扩展组件{
render(){
返回(
你好,世界!应用程序JS
它是{new Date().toLocaleTimeString()}
);
}
}
设定间隔(App,1000);

原因是
setInterval
。您正在尝试调用
App
构造函数,而不使用
new
关键字,而幕后React正在为您执行此操作

不要试图像这样调用它,而是在
App
类中引入一个状态(这次存储该状态),在每次间隔后更新该状态,并使用更新的时间重新呈现
App
JSX


另外,我假设您正在某处导入
App
类,并像

App
->
一样使用它,其中是
ReactDOM.render
?Index.js文件=>
导入React,{Fragment}来自'React';从“react dom”导入react dom;从“./components/App”导入应用程序;导入“./index.css”;ReactDOM.render(,document.getElementById('root'))