Created
June 4, 2019 22:48
-
-
Save srph/262838c6f815023fbc3fee7e6b8abdd9 to your computer and use it in GitHub Desktop.
React: Force route to remount (e.g., refetch data) when params change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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