React router Link not causing component to update within nested routes

后端 未结 5 1405
栀梦
栀梦 2021-02-07 14:46

This is driving me crazy. When I try to use React Router\'s Link within a nested route, the link updates in the browser but the view isn\'t changing. Yet if I refresh the page t

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-07 15:13

    I am uncertain whether it fixes the original problem, but I had a similar issue which was resolved by passing in the function callback () => this.forceUpdate() instead of this.forceUpdate.

    Since no one else is mentioning it, I see that you are using onClick={this.forceUpdate}, and would try onClick={() => this.forceUpdate()}.

提交回复
热议问题