Functions are not valid as a Rea

2022-09-22  本文已影响0人  Rose_yang
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.

如下源码导致报错
<Route path="/demo" element={Demo} />

原因:element 的值是组件 注意格式

修复如下:
<Route path="/demo" element={<Demo />} />

上一篇下一篇

猜你喜欢

热点阅读