Always use static/cached selectors in useSelector

This commit is contained in:
Jamie Kyle 2024-03-15 07:38:26 -07:00 committed by GitHub
parent d85a1d5074
commit 1e275a917c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 105 additions and 70 deletions

View file

@ -3,7 +3,6 @@
import React, { memo } from 'react';
import { useSelector } from 'react-redux';
import type { StateType } from '../reducer';
import { Inbox } from '../../components/Inbox';
import { getIntl } from '../selectors/user';
import { SmartCustomizingPreferredReactionsModal } from './CustomizingPreferredReactionsModal';
@ -15,6 +14,11 @@ import { SmartCallsTab } from './CallsTab';
import { useItemsActions } from '../ducks/items';
import { getNavTabsCollapsed } from '../selectors/items';
import { SmartChatsTab } from './ChatsTab';
import { getHasInitialLoadCompleted } from '../selectors/app';
import {
getInboxEnvelopeTimestamp,
getInboxFirstEnvelopeTimestamp,
} from '../selectors/inbox';
function renderChatsTab() {
return <SmartChatsTab />;
@ -41,17 +45,11 @@ export const SmartInbox = memo(function SmartInbox(): JSX.Element {
const isCustomizingPreferredReactions = useSelector(
getIsCustomizingPreferredReactions
);
const envelopeTimestamp = useSelector(
(state: StateType) => state.inbox.envelopeTimestamp
);
const firstEnvelopeTimestamp = useSelector(
(state: StateType) => state.inbox.firstEnvelopeTimestamp
);
const { hasInitialLoadCompleted } = useSelector(
(state: StateType) => state.app
);
const envelopeTimestamp = useSelector(getInboxEnvelopeTimestamp);
const firstEnvelopeTimestamp = useSelector(getInboxFirstEnvelopeTimestamp);
const hasInitialLoadCompleted = useSelector(getHasInitialLoadCompleted);
const navTabsCollapsed = useSelector(getNavTabsCollapsed);
const { toggleNavTabsCollapse } = useItemsActions();
return (