I'm trying to implement a facebook-like homepage (i.e. a list of posts with comments).
PostList
is the component in charge of loading the post list (using fetch in its componentDidMount()
), itself being a child of the component HomePage
.
I have another component for the navigation bar called NavBar
with a <Link>
component (from react-router-dom
) to the route of my HomePage
component ('/').
When I'm on any page other than '/', using the link works fine: the Router mounts HomePage
, and then PostList
triggering the componentDidMount()
and displaying the freshly retrieved posts.
But when I'm already on '/' the Link does nothing because well I'm already on '/', but I'd like it to still reload my component HomePage
so it can update its post list.
How can I do it ?