I have a React application built using React-Router-Dom for navigation. The pages are very heavy on use of tables of data that can be opened in a CRUD form. Due to the amount of records we have in the tables, it's not uncommon for the user to apply sorting, filtering, and paging to the tables in order to find a desired record.
As a fairly standard web application, we have a navigation bar on the left-hand side of the page. This is built up of NavLinks.
The main body of the application is a component, MainPanel
, that is almost entirely just a series of Route
components within a Switch
:
<Switch>
<Route path="/page1" component={ComponentOne} />
<Route path="/page2" component={ComponentTwo} />
</Switch>
I now have a request from above that when a user selects one of the NavLinks, it should act as a "reset" for everything in the main body of the page. In particular, this should act as a "reset" for all the settings of the table (sort, filter, page, etc.).
This seems like it should almost be trivial, as all I have to do is trigger a re-render of the main panel of the page holding the table. However, I can't find anything in the documentation for React-Router-Dom that holds the key to this.
Anybody got any idea what I'm missing? Is there no easy/right way to say, "When clicking this link, always re-render the MainPanel?