forked from react-navigation/react-navigation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: memoize getStateFromPath and getPathFromState (react-naviga…
…tion#12120) **_Problem_** When `getStateFromPath` receives big _linking config_ ([example](https://github.com/Expensify/App/blob/071f11ce1012db7d07eb750d74f58b552eba6144/src/libs/Navigation/linkingConfig/config.ts#L1152)) as an option parameter, it tends to slow down quite drastically. **_Investigations_** The config-related data is created every time`getStateFromPath` is called, resulting in noticeable overhead. Often times, configs provided to `getStateFromPath` are going to be static (e.g. initialised once at the app setup and remained untouched throughout its lifetime) and the data derived from it could also be static. **_Solution_** PR tries to improve `getStateFromPath` helper performance by extracting and caching calculations related to last linking config provided (due to its static nature, keeping reference to the latest value seems an OK heuristic). Here is an example of potential gains for Exfy app and its config: Expensify/App#48150 _**Test plan**_ No manual testing required. _**PR introduces**_ - [x] `getStateFromPath` config data caching - [x] `setTimeout` typings fixes
- Loading branch information
1 parent
35ff87b
commit 26463c8
Showing
7 changed files
with
175 additions
and
96 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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