Skip to content
This repository was archived by the owner on Nov 27, 2022. It is now read-only.

Commit b40156f

Browse files
committed
docs: update README
1 parent 12c8c87 commit b40156f

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

README.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Requires React Native version >= 0.36.
1717
- Both top and bottom tab bars
1818
- Follows Material Design spec
1919
- Highly customizable
20+
- Fully typed with [Flow](https://flow.org/)
2021

2122

2223
## Demo
@@ -34,14 +35,14 @@ yarn add react-native-tab-view
3435
## Example
3536

3637
```js
37-
import React, { Component } from 'react';
38+
import React, { PureComponent } from 'react';
3839
import { View, StyleSheet } from 'react-native';
3940
import { TabViewAnimated, TabBar, SceneMap } from 'react-native-tab-view';
4041

4142
const FirstRoute = () => <View style={[ styles.container, { backgroundColor: '#ff4081' } ]} />;
4243
const SecondRoute = () => <View style={[ styles.container, { backgroundColor: '#673ab7' } ]} />;
4344

44-
export default class TabViewExample extends Component {
45+
export default class TabViewExample extends PureComponent {
4546
state = {
4647
index: 0,
4748
routes: [
@@ -86,9 +87,10 @@ The package exposes the following components,
8687

8788
### `<TabViewAnimated />`
8889

89-
Container component responsible for managing tab transitions
90+
Container component responsible for managing tab transitions.
91+
92+
#### Props
9093

91-
It accepts the following props,
9294
- `navigationState` - the current navigation state
9395
- `onRequestChangeTab` - callback for when the current tab changes, should do the `setState`
9496
- `onChangePosition` - callback called with position value as it changes (e.g. - on swipe or tab change), avoid doing anything expensive here
@@ -104,9 +106,10 @@ Any other props are passed to the underlying pager.
104106

105107
### `<TabViewPagerPan />`
106108

107-
Pager component based on `PanResponder`
109+
Pager component based on `PanResponder`.
110+
111+
#### Props
108112

109-
It accepts the following props,
110113
- `configureTransition` - optional callback which returns a configuration for the transition
111114
- `animationEnabled` - whether to enable page change animation
112115
- `swipeEnabled` - whether to enable swipe gestures
@@ -116,39 +119,42 @@ It accepts the following props,
116119

117120
### `<TabViewPagerScroll />`
118121

119-
Pager component based on `ScrollView` (default on iOS)
122+
Pager component based on `ScrollView` (default on iOS).
123+
124+
#### Props
120125

121-
It accepts the following props,
122126
- `animationEnabled` - whether to enable page change animation
123127
- `swipeEnabled` - whether to enable swipe gestures
124128
- `children` - React Element(s) to render
125129

126130
### `<TabViewPagerAndroid />`
127131

128-
Pager component based on `ViewPagerAndroid` (default on Android)
132+
Pager component based on `ViewPagerAndroid` (default on Android).
133+
134+
#### Props
129135

130-
It accepts the following props,
131136
- `animationEnabled` - whether to enable page change animation
132137
- `swipeEnabled` - whether to enable swipe gestures
133138
- `children` - React Element(s) to render
134139

135140
### `<TabBar />`
136141

137-
Material design themed top tab bar
142+
Material design themed tab bar. Can be used as both top and bottom tab bar.
143+
144+
#### Props
138145

139-
It accepts the following props,
140146
- `getLabelText` - optional callback which receives the current scene and returns the tab label
141147
- `renderIcon` - optional callback which receives the current scene and returns a React Element to be used as a icon
142148
- `renderLabel` - optional callback which receives the current scene and returns a React Element to be used as a label
143149
- `renderIndicator` - optional callback which receives the current scene and returns a React Element to be used as a tab indicator
144150
- `renderBadge` - optional callback which receives the current scene and returns a React Element to be used as a badge
145-
- `onTabPress` - optional callback invoked on tab press, useful for things like scroll to top; receives the scene of the tab that was pressed
151+
- `onTabPress` - optional callback invoked on tab press which receives the scene for the pressed tab, useful for things like scroll to top
146152
- `pressColor` - color for material ripple (Android >= 5.0 only)
147153
- `pressOpacity` - opacity for pressed tab (iOS and Android < 5.0 only)
148154
- `scrollEnabled` - whether to enable scrollable tabs
149-
- `tabStyle` - style object for the tab
150-
- `indicatorStyle` - style object for the tab indicator
151-
- `labelStyle` - style object for the tab label
155+
- `tabStyle` - style object for the individual tabs in the tab bar
156+
- `indicatorStyle` - style object for the active indicator
157+
- `labelStyle` - style object for the tab item label
152158
- `style` - style object for the tab bar
153159

154160

@@ -159,7 +165,7 @@ Check the [type definitions](src/TabViewTypeDefinitions.js) for details on shape
159165

160166
`<TabViewAnimated />` is a `PureComponent` to prevent unnecessary re-rendering. As a side-effect, the tabs won't re-render if something changes in the parent's state/props. If you need it to trigger a re-render, put it in the `navigationState`.
161167

162-
For example, consider you have a `loaded` property on state which should trigger re-render. You can have your state like the following -
168+
For example, consider you have a `loaded` property on state which should trigger re-render. You can have your state like the following:
163169

164170
```js
165171
state = {

0 commit comments

Comments
 (0)