File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,10 @@ export class TabViewScreen extends React.Component {
12
12
title : 'Tab Set' ,
13
13
} ;
14
14
15
+ onItemChange = ( change ) => {
16
+ console . log ( `onItemChange: ${ JSON . stringify ( change , null , 2 ) } ` ) ;
17
+ } ;
18
+
15
19
render ( ) {
16
20
return (
17
21
< View style = { styles . container } >
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { RkTabPager } from './rkTabPager.component';
8
8
/**
9
9
* @extends React.Component
10
10
*
11
- * @property {function } onGalleryItemChange - Gallery (modal) item change callback
11
+ * @property {function } onItemChange - tab content change callback
12
12
*/
13
13
export class RkTabView extends React . Component {
14
14
static propTypes = {
@@ -36,15 +36,25 @@ export class RkTabView extends React.Component {
36
36
this . state . selectedIndex = this . tabViews . findIndex ( child => child . props . isSelected ) ;
37
37
}
38
38
39
+ componentDidMount ( ) {
40
+ this . props . onItemChange ( {
41
+ previous : null ,
42
+ current : this . state . selectedIndex ,
43
+ } ) ;
44
+ }
45
+
39
46
onTabSelect = ( index ) => {
40
47
this . tabPagerRef . scrollToIndex ( { index } ) ;
41
48
} ;
42
49
43
50
onTabContentSelect = ( index ) => {
51
+ this . props . onItemChange ( {
52
+ previous : this . state . selectedIndex ,
53
+ current : index ,
54
+ } ) ;
44
55
this . setState ( {
45
56
selectedIndex : index ,
46
57
} ) ;
47
- this . props . onItemChange ( index ) ;
48
58
} ;
49
59
50
60
setTabBarRef = ( ref ) => {
You can’t perform that action at this time.
0 commit comments