简体   繁体   English

错误:函数作为 React 子项无效。 不确定错误在哪里

[英]Error: Functions are not valid as a React child. Unsure of where error is

This is one of the two errors that I have encountered on the same application from my previous question.这是我在上一个问题的同一个应用程序中遇到的两个错误之一。 Here is the first error:这是第一个错误:

Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
Routes@http://localhost:3000/React-Portfolio/static/js/bundle.js:40930:7
div
div
Header@http://localhost:3000/React-Portfolio/static/js/bundle.js:581:1
Router@http://localhost:3000/React-Portfolio/static/js/bundle.js:40867:7
BrowserRouter@http://localhost:3000/React-Portfolio/static/js/bundle.js:40344:7
div
App

I am not sure how to debug this entirely so not really sure where it is saying the error exists... Here is the repository: https://github.com/kstaver/React-Portfolio我不确定如何完全调试它,所以不确定它在哪里说错误存在......这是存储库: https://github.com/kstaver/React-Portfolio

With react-router v6, you must pass an element as the value of element attribue on Route component, but you are sendeing component as element.使用 react-router v6,您必须将元素作为Route组件上的element属性的值传递,但您将组件作为元素发送。 To solve the problem you need to change <Route path="/about" element={About} /> to <Route path="/about" element={<About />} /> in all your routes.要解决此问题,您需要在所有路线中将<Route path="/about" element={About} />更改为<Route path="/about" element={<About />} /> Actually your routes must be configured like this:实际上,您的路线必须像这样配置:

 <Routes>
   <Route exact path="/" element={<Navigate to="/about" replace/>} />
   <Route path="/about" element={<About />} />
   <Route path="/portfolio" element={<Portfolio />} />
   <Route path="/contact" element={<Contact />} />
   <Route path="/resume" element={<Resume />} />
 </Routes>

暂无
暂无

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

相关问题 我如何解决“函数作为 React 子节点无效”的问题。 错误? - How can I solve 'Functions are not valid as a React child.' error? 函数作为React子代无效。 我在代码中找不到导致此错误的任何内容 - Functions are not valid as a React child. I can't find anything in my code that cause this error 错误函数作为 React 子级无效。 如果您返回 Component 而不是<Component />从渲染 - Error Functions are not valid as a React child. This can happen if you return a Component instead of <Component /> from render 如何解决“函数作为 React 子级无效”。 当我尝试根据函数的输出渲染组件时出错? - How to solve "Functions are not valid as a React child." error when I try to render a components based on the output of a function? 警告:函数作为 React 子级无效。 ReactJS - Warning: Functions are not valid as a React child. ReactJS 函数作为 React 子级无效。 - React 中的功能组件 - Functions are not valid as a React child. - Functional Components in React 错误:函数作为React子代无效 - Error: Functions are not valid as a React child 对象作为 React 子级无效。 如果您打算渲染一组子项,请改用数组 - 错误 Solidity - React - Objects are not valid as a React child. If you meant to render a collection of children, use an array instead - Error Solidity - React 未捕获的错误:对象作为 React 子项无效。 使用反应流编辑器时 - Uncaught Error: Objects are not valid as a React child. when using react-flow-editor Next JS REACT 中的错误:对象作为 React 子项无效。 只想使用日期 - Error in Next JS REACT: Objects are not valid as a React child. Just want to use dates
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM