Functions are not valid as a React child. This may happen if you return a Compon

367 阅读1分钟

react项目中配置路由是出现以下报错

Functions are not valid as a React child. This may happen if you return a Component instead of from render. Or maybe you meant to call this function rather than return it.

ab08860de7d9af86cab2408716dfa93.png

原因是老版本的react-router-dom,component的值,可以直接写,而新版的react-router-dom,elemen的值需要用</>包裹。

原代码

image.png

修改后

image.png