react-router4 Route中的children属性作用是什么

看了官方文档,没想明白是干什么的,和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>

);


胡子哥哥
浏览 566回答 2
2回答

MMMHUHU

找到官方解释了Sometimes you need to render whether the path matches the location or not. In these cases, you can use the function children prop. It works exactly like render except that it gets called whether there is a match or not.
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript