Background
useCurrentUserPersonalDetails is a hook that provides personal details of the user account and is most commonly used to acquire the accountID or other static data related to the user (which rarely changes). It is widely used, with approximately 220 components depending on it—either through direct use of useCurrentUserPersonalDetails or indirectly via WithCurrentUserPersonalDetails or AccessOrNotFoundWrapper.
Problem
Its current implementation is suboptimal, as it depends on usePersonalDetails. This causes components that use useCurrentUserPersonalDetails to re-render even when unrelated personal details change. In other words, every time any personal data of any user is updated, the components using useCurrentUserPersonalDetails will be forced to re-render unnecessarily.
Solution
Remove the usePersonalDetails hook and replace it with useOnyx, applying a selector to retrieve only the current user's data::
const [userPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: (allPersonalDetails) => allPersonalDetails?.[userAccountID]});
Benefits
On screens that have a lot of usage of useCurrentUserPersonalDetails many rerenders can be stopped.
In the following scenario:
- user is on the Reports "Pay" page
- user has a lot of screens in the history
- user starts a chat with a new person(which updates old useCurrentUserPersonalDetails , but doesn't do it with the new implementation)
This can cut down total react work from ~1300 ms to ~1200 ms on iOS.
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~021964988471047385327
- Upwork Job ID: 1964988471047385327
- Last Price Increase: 2025-09-08
Issue Owner
Current Issue Owner: @shubham1206agra
Background
useCurrentUserPersonalDetailsis a hook that provides personal details of the user account and is most commonly used to acquire the accountID or other static data related to the user (which rarely changes). It is widely used, with approximately 220 components depending on it—either through direct use ofuseCurrentUserPersonalDetailsor indirectly viaWithCurrentUserPersonalDetailsorAccessOrNotFoundWrapper.Problem
Its current implementation is suboptimal, as it depends on
usePersonalDetails. This causes components that useuseCurrentUserPersonalDetailsto re-render even when unrelated personal details change. In other words, every time any personal data of any user is updated, the components usinguseCurrentUserPersonalDetailswill be forced to re-render unnecessarily.Solution
Remove the
usePersonalDetailshook and replace it withuseOnyx, applying a selector to retrieve only the current user's data::const [userPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST, {selector: (allPersonalDetails) => allPersonalDetails?.[userAccountID]});Benefits
On screens that have a lot of usage of
useCurrentUserPersonalDetailsmany rerenders can be stopped.In the following scenario:
This can cut down total react work from ~1300 ms to ~1200 ms on iOS.
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @shubham1206agra