Skip to content

Instantly share code, notes, and snippets.

@srph
Created June 4, 2019 22:48
Show Gist options
  • Save srph/262838c6f815023fbc3fee7e6b8abdd9 to your computer and use it in GitHub Desktop.
Save srph/262838c6f815023fbc3fee7e6b8abdd9 to your computer and use it in GitHub Desktop.
React: Force route to remount (e.g., refetch data) when params change
/**
* Little trick to force our component to remount entirely if the user
* creates a tracker all while viewing another tracker.
*/
function WrappedDashboardTracker(props: Props) {
return (
<DashboardTracker key={props.match.params.trackerId} {...props} />
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment