You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{withRouter}from'react-router';constShowTheLocation=({ match, location, history})=>{return(<div>You are now at {location.pathname}</div>);}exportdefaultwithRouter(ShowTheLocation);
由于我看的是4.X版本,有些用法和2、3版本有点区别。
Link
需要从react-router-dom
中去引用。Route
不允许这样嵌套。应该是平级的书写方式
可以嵌套一个
Switch
来只匹配一个组件渲染。路径匹配语法
withRouter
withRouter是一个hoc,可以把路由的一些信息当作props传递到组件中,并返回一个新的组件。
The text was updated successfully, but these errors were encountered: