日记
行也成文 4/13/2020
# 日记
# React-router 的 <Route /> 的三个渲染方法的问题
官网原文:
The recommended method of rendering something with a
<Route>is to usechildrenelements, as shown above. There are, however, a few other methods you can use to render something with a<Route>. These are provided mostly for supporting apps that were built with earlier versions of the router before hooks were introduced.
<Route component>(opens new window)<Route render>(opens new window)<Route children>function (opens new window)You should use only one of these props on a given
<Route>. See their explanations below to understand the differences between them.
<Route /> 有三个渲染方法:
- component
- render
- children
参考:
react-Router的使用及原理讲解和实现react-Router - segmentfault (opens new window) React router的Route中component和render属性的使用 - 简书 (opens new window)