Description
Version
I'm using react-router-dom v5.0.0
Test Case
https://codesandbox.io/s/31vx2njxn1
Steps to reproduce
Go to password field and write: dummy
Expected Behavior
Render the HeaderComponent to update the links that must appear into the nav bar after user logged in.
Actual Behavior
The actual version (5.0.0) is not re-rendering the component after the user has logged in, the system must valid the boolean value called isUserLoggedIn that is defined in AuthenticationService.js, that value gets the item saved into the sessionStorage.
The LoginComponent has a simple method called loginClicked() where validates the username and password and ref to /welcome/username using this.props.history.push() that changes the url and page but does not update the nav bar where validates which links are going to be displayed.
This issue does not appear in react-router-dom 4.3.1.
Is there another way to set my components and methods to re-render the nav bar?
Activity
sudhiry commentedon Apr 8, 2019
HeaderComponent was not getting re-rendered as props are not getting changed for the component.
There are 3 ways to fix this.
KosKou commentedon Apr 8, 2019
Thanks for the quick response dude, i have solved it by adding withRouter(HeaderComponent) at the default export.
Fixing issue in28minutes#1
mhanchini commentedon Mar 27, 2020
could you please show me which code Router(HeaderComponent) that I have to change. I am using react-router-dom 5.1.2 and still not updated the "re-render the nav bar"
mayank8318 commentedon May 2, 2020
@mhanchini Here is the sample code:
kyocoolcool commentedon May 23, 2020
@mayank8318 thanks your support, it's worked.