看了官方文档,没想明白是干什么的,和Route的render
属性有什么区别?
const OldSchoolMenuLink = ({ label, to, activeOnlyWhenExact }) => (
<Route path={to} exact={activeOnlyWhenExact} children={({match}) => (
<div className={match ? 'active' : ''}>
{match ? '>' : ''}<Link to={to}>{label}</Link>
</div>
)}></Route>
);
Route
渲染组件的三种方式component
最常用,只有匹配location
才会加载component
对应的 React组件render
路由匹配函数就会调用children
不管路由是否匹配都会渲染对应组件