

Import * as React from 'react' import )īy using my custom useHistory, performances were back to normal on route changes. Since the history prop is not likely to change (or even probably never changes since it's a mutable object, but still not a hundred percent sure) i decided to implement a custom context which will act as a "tank-and-proxy" of the react-router context for the history props: This means that at every route change, there is every components using useHistory which re-render, and even while using memo in some of them the performance are not that great. I use useHistory (mostly for calling navigation methods) in a lot of components which stay mounted even when a route change since my application is mostly modal-based.

Since it should not be a problem in most applications, my use case was one where the re-render caused at every route changes were a major performance issue.
