React router 4 does not update view on link, but does on refresh

前端 未结 4 1985
暖寄归人
暖寄归人 2020-12-01 17:28

I am using the following simple nav code


  
    
    

        
4条回答
  •  悲&欢浪女
    2020-12-01 18:18

    You can also use the:

    import { withRouter } from 'react-router-dom';
    

    And then on your export default, you do like this:

    export default withRouter(connect(mapStateToProps, {})(Layout));
    

    Because when you have an export connect, you need to tell that that component will be using the router.

提交回复
热议问题