简体   繁体   English

将组件传递给 react 中的 app.js 文件时,它会编译,但浏览器会继续加载并且不显示任何内容

[英]When passing a component to the app.js file in react, it compiles but the browser keeps loading and doesnt show anything

This is the app.js code.这是 app.js 代码。

在此处输入图像描述

This is the Footer component file code.这是页脚组件文件代码。

在此处输入图像描述

In React.Component you only initialize the state with 'state=...' once, in constructor.在 React.Component 中,您只需在构造函数中使用 'state=...' 初始化 state 一次。 So remove the state={} from your components.所以从你的组件中删除 state={} 。 If you want to change the initial state, use setState().如果要更改初始 state,请使用 setState()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM