[英]Footer Causing React application to not load
import React from 'react';
// import './Footer.css';
export default function Footer() {
return (
<Footer>
{/* <p href= ''><i class='fa-brands fa-square-github' ></i></p> */}
<p href='https://github.com/Zac0088'><i class='fa-brands fa-linkedin' ></i></p>
<p href='https://github.com/Zac0088'><i class='fa-brands fa-discord' ></i></p>
</Footer>
);
}
i am trying to launch my react app and when i do NPM start the app compiles but chrome will not load the app just gives me Error code: Out of Memory.我正在尝试启动我的 React 应用程序,当我启动 NPM 时,应用程序会编译,但 chrome 不会加载该应用程序,只会给我错误代码:内存不足。 It has somthing to do with the footer when i remove the footer tag from the portfolio container it loads, but with it i get the above error.
当我从它加载的投资组合容器中删除页脚标签时,它与页脚有关,但是我得到了上述错误。
import React, { useState } from 'react';
import NavTabs from './NavTabs';
import Home from './pages/Home';
import Projects from './pages/Projects'
// import About from './pages/Home';
import Resume from './pages/Resume';
import Contact from './pages/Contact';
import Footer from './Footer';
export default function PortfolioContainer() {
const [currentPage, setCurrentPage] = useState('Home');
// This method is checking to see what the value of `currentPage` is. Depending on the value of currentPage, we return the corresponding component to render.
const renderPage = () => {
if (currentPage === 'Home') {
return <Home />;
}
if (currentPage === 'Projects') {
return <Projects />;
}
if (currentPage === 'Resume') {
return <Resume />;
}
return <Contact />;
};
const handlePageChange = (page) => setCurrentPage(page);
return (
<div>
<div className="portfolio-container">
{/* We are passing the currentPage from state and the function to update it */}
<NavTabs currentPage={currentPage} handlePageChange={handlePageChange} />
{/* Here we are calling the renderPage method which will return a component */}
{renderPage()}
</div>
<Footer />
</div>
);
}
You are calling the function Footer
within itself, causing an infinite loop.您在自身内部调用函数
Footer
,导致无限循环。
When the Footer component renders you are returning <Footer>
, which is actually the same function, which causes Footer to render itself over and over again until the browser runs out of space to store all of them.当 Footer 组件呈现时,您将返回
<Footer>
,这实际上是相同的功能,这会导致 Footer 一遍又一遍地呈现自己,直到浏览器用完所有空间来存储它们。
You probably meant to use the <footer>
HTML element instead.您可能打算改用
<footer>
HTML 元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.