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

underline position is incorrect if `initialPage` is set after react-native 0.36

Open chunghe opened this issue 10 years ago • 14 comments

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

2016-11-09 16 06 43

might related to issue #458

chunghe avatar Nov 09 '16 08:11 chunghe

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.

chunghe avatar Nov 09 '16 08:11 chunghe

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.

demo

chunghe avatar Nov 14 '16 03:11 chunghe

Would you like to open issue in react-native repository?

skv-headless avatar Nov 14 '16 11:11 skv-headless

sure. will do.

chunghe avatar Nov 15 '16 07:11 chunghe

@chunghe could you please attach react-native issue to this issue?

skv-headless avatar Nov 23 '16 16:11 skv-headless

@chunghe Any news on this? I'm on RN 0.39 with React 15.4 and issue is still here.

scarlac avatar Dec 05 '16 14:12 scarlac

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>

scarlac avatar Dec 05 '16 15:12 scarlac

I encountered this today as well. Any updates?

meros avatar Mar 09 '17 14:03 meros

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.

ischenkodv avatar Mar 30 '17 08:03 ischenkodv

This appears to be fixed on 0.7.4 for me

ghuh avatar Apr 15 '17 06:04 ghuh

+1, it is running ok, without workaround, on [email protected] and [email protected]

ColCh avatar Aug 31 '17 20:08 ColCh

im using 0.8.0 and its not working

yotavm avatar Oct 29 '17 15:10 yotavm

the workaround doesn't seem to work on 0.8.0

raghudevan avatar Nov 26 '17 15:11 raghudevan

doesn't work on 0.8.0 , react-native0.55.4

meiqi1992 avatar Jun 29 '18 06:06 meiqi1992