-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTabViewExample.js
More file actions
33 lines (27 loc) · 838 Bytes
/
Copy pathTabViewExample.js
File metadata and controls
33 lines (27 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as React from 'react';
import {View, useWindowDimensions} from 'react-native';
import {TabView, SceneMap} from 'react-native-tab-view';
const FirstRoute = () => <View style={{flex: 1, backgroundColor: '#ff4081'}} />;
const SecondRoute = () => (
<View style={{flex: 1, backgroundColor: '#673ab7'}} />
);
export default function TabViewExample() {
const layout = useWindowDimensions();
const [index, setIndex] = React.useState(0);
const [routes] = React.useState([
{key: 'first', title: 'First'},
{key: 'second', title: 'Second'},
]);
const renderScene = SceneMap({
first: FirstRoute,
second: SecondRoute,
});
return (
<TabView
navigationState={{index, routes}}
renderScene={renderScene}
onIndexChange={setIndex}
initialLayout={{width: layout.width}}
/>
);
}