When viewing an account history, if one navigates to an entry's details and then hits the "go back" button, it should take you back to where you were in the paginated history list.
In this PR
lift-up the state tracking of both pagination (firstToShow) and filtering (selectedTabIndex) from the HistoryList component to the HistoryPage component so that this state is not lost due to HistoryPage rendering the TransactionDetails component instead of the HistoryList component when the user clicks on a list entry, and next clicks the Go Back button.
Caveats
This PR just passes the setters for firstToShow and selectedTabIndex into HistoryList, having lifted the state tracking up to HistoryPage. While the practice of directly sharing state setters into sub-components is generally frowned upon, that is for the use case of sharing state between sub-components and to make the code more debuggable when unexpected state changes happen.
We think in this case, it is acceptable because all of the setting is being done in HistoryList. We just need to lift these pieces of state up to the enclosing component as it removes HistoryList from the tree and then returns it later and we want this bit of state to survive that toggling of what is displayed.
Motivation
When viewing an account history, if one navigates to an entry's details and then hits the "go back" button, it should take you back to where you were in the paginated history list.
In this PR
firstToShow
) and filtering (selectedTabIndex
) from theHistoryList
component to theHistoryPage
component so that this state is not lost due toHistoryPage
rendering theTransactionDetails
component instead of theHistoryList
component when the user clicks on a list entry, and next clicks theGo Back
button.Caveats
This PR just passes the setters for
firstToShow
andselectedTabIndex
intoHistoryList
, having lifted the state tracking up toHistoryPage
. While the practice of directly sharing state setters into sub-components is generally frowned upon, that is for the use case of sharing state between sub-components and to make the code more debuggable when unexpected state changes happen.We think in this case, it is acceptable because all of the setting is being done in
HistoryList
. We just need to lift these pieces of state up to the enclosing component as it removesHistoryList
from the tree and then returns it later and we want this bit of state to survive that toggling of what is displayed.