Skip to content

Commit 17d0e0a

Browse files
committed
Fix PR comments
1 parent 94c3c69 commit 17d0e0a

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

generatedTypes/components/tabController/index.d.ts

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React from 'react';
1+
import React, { Component } from 'react';
2+
import Reanimated from 'react-native-reanimated';
23
import TabBar from './TabBar';
34
import TabBarItem, { TabBarItemProps } from './TabBarItem';
45
import TabPage from './TabPage';
@@ -26,12 +27,50 @@ export interface TabControllerProps {
2627
*/
2728
carouselPageWidth?: number;
2829
}
30+
interface StateProps {
31+
selectedIndex: number;
32+
asCarousel?: boolean;
33+
pageWidth: number;
34+
items: TabControllerProps['items'];
35+
itemStates: any[];
36+
ignoredItems: any[];
37+
targetPage: any;
38+
currentPage: any;
39+
carouselOffset: any;
40+
containerWidth: any;
41+
registerTabItems: (tabItemsCount: number, ignoredItems: StateProps['ignoredItems']) => void;
42+
onChangeIndex: (index: number) => void;
43+
}
44+
/**
45+
* @description: A performant solution for a tab controller with lazy load mechanism
46+
* @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/componentScreens/TabControllerScreen/index.js
47+
* @notes: This component is based on react-native-gesture-handler
48+
* @important: On Android, if using react-native-navigation, make sure to wrap your screen with gestureHandlerRootHOC
49+
* @importantLink: https://kmagiera.github.io/react-native-gesture-handler/docs/getting-started.html#with-wix-react-native-navigation-https-githubcom-wix-react-native-navigation
50+
*/
51+
declare class TabController extends Component<TabControllerProps, StateProps> {
52+
static displayName: string;
53+
static contextType: React.Context<{}>;
54+
static TabBar: typeof TabBar;
55+
static TabBarItem: typeof TabBarItem;
56+
static TabPage: typeof TabPage;
57+
static PageCarousel: typeof PageCarousel;
58+
static defaultProps: {
59+
selectedIndex: number;
60+
activeOpacity: number;
61+
};
62+
constructor(props: TabControllerProps);
63+
static getDerivedStateFromProps(nextProps: TabControllerProps, prevState: StateProps): {
64+
pageWidth: number;
65+
} | null;
66+
componentDidUpdate(_prevProps: TabControllerProps, prevState: StateProps): void;
67+
get pageWidth(): number;
68+
registerTabItems: (tabItemsCount: number, ignoredItems: StateProps['ignoredItems']) => void;
69+
onPageChange: ([index]: readonly number[]) => void;
70+
renderCodeBlock: () => Reanimated.Node<number>;
71+
render(): JSX.Element;
72+
}
2973
declare const _default: React.ComponentClass<TabControllerProps & {
3074
useCustomTheme?: boolean | undefined;
31-
}, any> & {
32-
TabBar: typeof TabBar;
33-
TabBarItem: typeof TabBarItem;
34-
TabPage: typeof TabPage;
35-
PageCarousel: typeof PageCarousel;
36-
};
75+
}, any> & typeof TabController;
3776
export default _default;

src/components/tabController/TabBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class TabBar extends PureComponent<Props, State> {
291291
targetOffset = scrollingWidth - targetOffset;
292292
}
293293

294-
if (this.tabBar && this.tabBar.current) {
294+
if (this.tabBar?.current) {
295295
this.tabBar.current.scrollTo({x: targetOffset, animated});
296296
}
297297
}

src/components/tabController/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,6 @@ TabController.TabPage = TabPage;
239239
TabController.PageCarousel = PageCarousel;
240240
export default asBaseComponent<
241241
TabControllerProps,
242-
{
243-
TabBar: typeof TabBar;
244-
TabBarItem: typeof TabBarItem;
245-
TabPage: typeof TabPage;
246-
PageCarousel: typeof PageCarousel;
247-
}
242+
typeof TabController
248243
//@ts-ignore typescript - will be fixed when moved to functional component
249244
>(TabController);

0 commit comments

Comments
 (0)