[BUG] ScrollableTabBar's text is not scrollable.
When there are too many tabs or the tabs include too many words, the width of the ScrollableTabBar is only equal to the width of the screen.
When there are only a few tabs e.g. 3 tabs, the ScrollableTabBar can be displayed normally.
@skv-headless
https://appetize.io/embed/6qfv7eydjtm34mhn6qwj2nt3xm?embed=true&screenOnly=false&xdocMsg=true&debug=true&scale=100&deviceColor=black&orientation=portrait&device=iphone6s&osVersion=9.3&deviceId=RGV2aWNlOjU2Y2FjNTExZWQwOTM2MTEwMGRhYTNlNg&platform=ios&width=375&height=668&phoneWidth=416&phoneHeight=870&screenOffsetLeft=21&screenOffsetTop=100¶ms=%7B%7D it is working in example. Could you share code snippet?
I found the reason why this bug occurred.
First, I set two tabs. In this case, the ScrollableTabBar did initialized. After I got some data from the server, the data created some tabs in ScrollableTabBar. Then, the bug above came out. It seems dynamically to change the count of ScrollableTabBar, it happened.
I have no idea how to fix it.
@skv-headless
Maybe. I don't use dynamic tab generation. Not sure when I'll be able to take a look
code snippet:
import React from 'react';
import {
StyleSheet,
Text,
View,
} from 'react-native';
import ScrollableTabView, { ScrollableTabBar, } from 'react-native-scrollable-tab-view';
export default React.createClass({
getInitialState() {
return {
showMore: false,
};
},
componentDidMount() {
setTimeout(() => {
this.setState({
showMore: true,
});
}, 2000);
},
renderContents() {
return [
<Text key={3} tabLabel='Tab #3 word '>project</Text>,
<Text key={4} tabLabel='Tab #4 word'>favorite</Text>,
<Text key={5} tabLabel='Tab #5'>project</Text>,
];
},
render() {
return <View style={styles.container}>
<ScrollableTabView initialPage={0} renderTabBar={() => <ScrollableTabBar />}>
<Text tabLabel='Tab #1'>My</Text>
<Text tabLabel='Tab #2 word'>favorite</Text>
{this.state.showMore && this.renderContents()}
</ScrollableTabView>
</View>;
},
});
const styles = StyleSheet.create({
container: {
flex: 1,
marginTop: 30,
},
});
<ScrollableTabBar key={this.state.showMore?'1':'0'}/>
Is this still an issue?
This appears to be the same problem fixed by https://github.com/skv-headless/react-native-scrollable-tab-view/pull/362
Cool 👍 Reopen if needed.
//scrollableTabbar.js
hi guys, i encounter this very same problem today ,finally i find a solution ,probably bad, but it works for me
onTabContainerLayout(e) {
this._tabContainerMeasurements = e.nativeEvent.layout;
let width = this._tabContainerMeasurements.width;
if (width < WINDOW_WIDTH) {
width = WINDOW_WIDTH;
}
this.setState({ _containerWidth: width, }); // modify 'width' => null solved my problem
this.updateView({value: this.props.scrollValue.__getValue(), });
},
Hello. @skv-headless if I have something like this
<ScrollableTabView
style={{ marginTop: 5 }}
locked={disabled}
//page={ props.selectedTab }
//initialPage={ props.selectedTab }
onChangeTab={props.onSelect}
//renderTabBar={() => <ScrollableTabBar />}
>
{
tabs.map((tab, i) => (
<ScrollView
scrollEventThrottle={16}
key={i}
tabLabel={tab.label}
>
{tab.content}
</ScrollView>
))
}
</ScrollableTabView>
`
I'm not getting the width correclty displayed.. it shows all tabs with a fixed width. To solve this should a create my own toolbar and there set the width?
Hooo my bad... I didn't realize the component was called ScrollableTabBar. I'm using it and it's scrolling although the animation is stuck sometimes.