react-native-tab-view icon indicating copy to clipboard operation
react-native-tab-view copied to clipboard

tab indicator position error

Open hanxk opened this issue 9 years ago • 3 comments

when i swipe tab, the second tab position error.

ezgif-4-9ad4d38ebd

import React, { PureComponent } from 'react';
import { View, StyleSheet } from 'react-native';
import { TabViewAnimated, TabBar, SceneMap } from 'react-native-tab-view'; // 0.0.69

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

export default class TabViewExample extends PureComponent {
  state = {
    index: 0,
    routes: [
      { key: '1', title: 'Test1' },
      { key: '2', title: 'Test2' },
      { key: '3', title: 'Test3' },
      { key: '4', title: 'Test4' },
    ],
  };

  _handleIndexChange = index => this.setState({ index });

  _renderHeader = (props) => {
    return (
      <TabBar {...props}  tabStyle={{width:130}} scrollEnabled={true} />
    );
  }

  _renderScene = SceneMap({
    '1': FirstRoute,
    '2': SecondRoute,
    '3': FirstRoute,
    '4': SecondRoute,
  });

  render() {
    return (
      <TabViewAnimated
        style={styles.container}
        navigationState={this.state}
        renderScene={this._renderScene}
        renderHeader={this._renderHeader}
        onIndexChange={this._handleIndexChange}
      />
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

snap source code: https://snack.expo.io/ry4ZPrJjZ

hanxk avatar Sep 24 '17 08:09 hanxk

Same, I'm having the same issue. However it seems that if I don't set an explicit width, it works. But when I do set a width, it breaks.

feiyingx avatar Sep 28 '17 00:09 feiyingx

Yes, I am facing a similar issue. I am trying to place another action item just beside the tab navigator but on doing so the size of the active tab doesn't adjust accordingly.

Bharat23 avatar Jan 03 '18 08:01 Bharat23

Hey, I just released a new alpha 2.0.0-alpha.0 of the library. It's rewritten using react-native-gesture-handler and react-native-reanimated addresses a many platform specific bugs and performance problems. The documentation is updated as well.

Please try the new version and see if it addresses your issue. If not, please open a new issue following the issue template.

satya164 avatar Feb 19 '19 22:02 satya164