Skip to content

Commit

Permalink
replace withOnyx with useOnyx
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardoj committed May 28, 2024
1 parent e5a1366 commit 80ae175
Showing 1 changed file with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import Breadcrumbs from '@components/Breadcrumbs';
import Icon from '@components/Icon';
import * as Expensicons from '@components/Icon/Expensicons';
Expand All @@ -17,20 +16,15 @@ import * as Session from '@userActions/Session';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Policy, Session as SessionType} from '@src/types/onyx';

type TopBarOnyxProps = {
policy: OnyxEntry<Policy>;
session: OnyxEntry<Pick<SessionType, 'authTokenType'>>;
};
type TopBarProps = {breadcrumbLabel: string; activeWorkspaceID?: string; shouldDisplaySearch?: boolean};

// eslint-disable-next-line react/no-unused-prop-types
type TopBarProps = {breadcrumbLabel: string; activeWorkspaceID?: string; shouldDisplaySearch?: boolean} & TopBarOnyxProps;

function TopBar({policy, session, breadcrumbLabel, shouldDisplaySearch = true}: TopBarProps) {
function TopBar({breadcrumbLabel, activeWorkspaceID, shouldDisplaySearch = true}: TopBarProps) {
const styles = useThemeStyles();
const theme = useTheme();
const {translate} = useLocalize();
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID}`);
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: (session) => session && {authTokenType: session.authTokenType}});

Check failure on line 27 in src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/TopBar.tsx

View workflow job for this annotation

GitHub Actions / Run ESLint

'session' is already declared in the upper scope on line 27 column 12
const isAnonymousUser = Session.isAnonymousUser(session);

const headerBreadcrumb = policy?.name
Expand Down Expand Up @@ -84,12 +78,4 @@ function TopBar({policy, session, breadcrumbLabel, shouldDisplaySearch = true}:

TopBar.displayName = 'TopBar';

export default withOnyx<TopBarProps, TopBarOnyxProps>({
policy: {
key: ({activeWorkspaceID}) => `${ONYXKEYS.COLLECTION.POLICY}${activeWorkspaceID}`,
},
session: {
key: ONYXKEYS.SESSION,
selector: (session) => session && {authTokenType: session.authTokenType},
},
})(TopBar);
export default TopBar;

0 comments on commit 80ae175

Please sign in to comment.