underline position is incorrect if `initialPage` is set after react-native 0.36
react-native version: 0.36 platform: ios (android is not affected)
following is the code snippet to reproduce this bug. SimpleExample.js with initialPage={1}.
import React from 'react';
import {
Text,
} from 'react-native';
import ScrollableTabView, {DefaultTabBar, } from 'react-native-scrollable-tab-view';
export default React.createClass({
render() {
return <ScrollableTabView
initialPage={1} // <--- set initialPage
style={{marginTop: 20, }}
renderTabBar={() => <DefaultTabBar />}
>
<Text tabLabel='Tab #1'>My</Text>
<Text tabLabel='Tab #2'>favorite</Text>
<Text tabLabel='Tab #3'>project</Text>
</ScrollableTabView>;
},
});
The Tab#2 is highlighted, but the underline appears under Tab#1
might related to issue #458
I dig the code a little bit, it seems onScroll is called after scrollView rendered, then get the offsetX (which is 0) from event, and this. _updateScrollValue will update the the scrollValue to 0.
It seems this bug only happens with 'Debug JS Remotely' enabled. The following is the screen recording, first with 'Debug JS Remotely' disable, then enable. You can see the underline position is incorrect is debugger is on.

Would you like to open issue in react-native repository?
sure. will do.
@chunghe could you please attach react-native issue to this issue?
@chunghe Any news on this? I'm on RN 0.39 with React 15.4 and issue is still here.
For those looking for a workaround, I'm currently using this:
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
// Workaround for #470: github.com/skv-headless/react-native-scrollable-tab-view/issues/470
setTimeout(() => {
this.scrollableTabView._updateScrollValue(this.props.initialPage);
}, 1);
});
}
(...)
render() {
<ScrollableTabView
locked
ref={ref => this.scrollableTabView = ref}
initialPage={this.props.initialPage || 0} /* doesn't work reliably, see componentDidMount() */
>
<Tab1 tabLabel="Spend"/>
<Tab2 tabLabel="Categories"/>
<Tab3 tabLabel="Merchants"/>
</ScrollableTabView>
I encountered this today as well. Any updates?
This one seems to be fixed. I encountered this bug in 0.7.2 and it is gone when I upgraded to 0.7.3.
This appears to be fixed on 0.7.4 for me
+1, it is running ok, without workaround, on [email protected] and [email protected]
im using 0.8.0 and its not working
the workaround doesn't seem to work on 0.8.0
doesn't work on 0.8.0 , react-native0.55.4