Skip to content

Commit 823c404

Browse files
jainkuniyagnprice
authored andcommitted
accountPickerScreen: Fix re-render on every event of long poll.
Use `reselect` in `getAccountStatuses`, so that it memorize accounts and return same object for same value and saves re-render.
1 parent 19a51fc commit 823c404

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/account/accountsSelectors.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ export type AccountStatus = {| ...Identity, isLoggedIn: boolean |};
1414
* This should be used in preference to `getAccounts` where we don't
1515
* actually need the API keys, but just need to know whether we have them.
1616
*/
17-
export const getAccountStatuses = (state: GlobalState): AccountStatus[] => {
18-
const accounts = getAccounts(state);
19-
return accounts.map(({ realm, email, apiKey }) => ({ realm, email, isLoggedIn: apiKey !== '' }));
20-
};
17+
export const getAccountStatuses: Selector<$ReadOnlyArray<AccountStatus>> = createSelector(
18+
getAccounts,
19+
accounts =>
20+
accounts.map(({ realm, email, apiKey }) => ({ realm, email, isLoggedIn: apiKey !== '' })),
21+
);
2122

2223
/**
2324
* All known accounts, indexed by identity.

0 commit comments

Comments
 (0)