路由渲染函数不返回或渲染任何元素

Route render function not returning or rendering any element

所以我是 React.js 的新手,无法从 Route 模块渲染元素。 控制台返回 location 的叶路由没有元素,因此呈现一个空页面。 其他使用“元素”功能的路由标签可以正常工作,这个也是如此。 这是来自 App.js 文件

的片段
          <Route
        path="/"
        render={(props) => (
          <ContactList
            {...props}
            contacts={contacts}
            getContactId={removeContactHandler}
          />
        )}
      />

我一直在关注 youtube 教程,希望能快速学习 React。现在,本教程中使用的一些函数目前已弃用。那么我应该使用其他功能来代替这个吗?感谢任何帮助

编辑: render 和 component 函数都被 element prop 代替了,我发现 this answer 有用

最近更新了 React 路由器文档!含义语法已更改。看看这里

如果有人想知道,从版本 6 开始,rendercomponent props 被替换为 element prop,它作为文字而不是通过箭头函数传递 ()=>{}This answer 解释得更清楚一些。