Skip to content

[Due for payment 2025-09-19] [$250] Refactor useCurrentUserPersonalDetails to use useOnyx with selector #70056

Description

@SzymczakJ

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:

  1. user is on the Reports "Pay" page
  2. user has a lot of screens in the history
  3. 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 OwnerCurrent Issue Owner: @shubham1206agra

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2ExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions