【React】用了connected-react-router必定要让一个组件用withRouter或者Route包裹才能获取路由方法?

前言 有个小伙伴发问:为何一个组件要用withRouter包裹?不是使用了connected-react-router把路由信息存到store了吗? 我仔细一想,以为颇有道理,其实确实能够不经过withRouter包裹获取history方法。 前置知识 咱们知道,withRouter其实至关于<Route component={xxxx}/>,而最上层是被Router包裹的,为此有基于Router
相关文章
相关标签/搜索