产生"Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render."错误
通常是因为以下两个原因:
render
中返回一个函数引用而不是一个组件。<Route path="/about" element={About} />
,而不是<Route path="/about" element={<About />} />
。这里有个例子来展示错误是如何发生的。
// App.js /** * ⛔️ 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. */ const App = () => { const getButton = () => { return <button>Click</button>; }; //相关文章
- React中的Hooks路由跳转问题
- 解决React报错Cannot assign to 'current' because it
- 解决React报错The tag is unrecognized in this
- 解决React报错Style prop value must be an object
- vue3中如何使用ref和reactive定义和修改响应式数据(最
- 解决React报错useNavigate() may be used only i
- React高阶组件使用教程详解
- react component changing uncontrolled input报错解
- 绝地求生运行游戏BattlEye Launcher报错怎么办
- React组件实例三大核心属性State props Refs详解
- python中base64编码简介