ptomasroos / react-native-scrollable-tab-view

Tabbed navigation that you can swipe between, each tab can have its own ScrollView and maintain its own scroll position between swipes. Pleasantly animated. Customizable tab bar
https://www.npmjs.com/package/react-native-scrollable-tab-view
6.94k stars 2.28k forks source link

[ onChangeTab ] open debugging mode is normal, but "stop Remote js Debugging" the app will slow and crash. #1007

Open swdenglian opened 5 years ago

swdenglian commented 5 years ago

this problem like #1004 and #888 when you trigger onChangeTab event.( android and ios )

demo code:

 <ScrollableTabView
        onChangeTab={onChangeTab}
        locked={locked}
        renderTabBar={(props) => <DefaultTabBar {...{ ...props, tabBarItemPosition }} />}
      >
        {tabViewChildren}
</ScrollableTabView>

有问题的代码:

https://github.com/ptomasroos/react-native-scrollable-tab-view/blob/9d5d0f4aedc886e17f6be9d2e29d8adef6de654a/index.js#L307-L313

If you comment out this code(ref line), there will be no problem. 注释以上代码中的 ref 那一行 这个问题将得到解决。但是不知道是为什么。

 _onChangeTab(prevPage, currentPage) { 
   this.props.onChangeTab({ 
     i: currentPage, 
  //   ref: this._children()[currentPage], 
     from: prevPage, 
   }); 
 }, 

最后表示感谢,Thank you for your work.

Greendelwold commented 5 years ago

try this: ` <View style={{flex: 1}}>

` wrapped with View, hope it works for you

Tracklous commented 5 years ago

Actually yes the problem is with the onChangeTab make sure you have not put any console logs or console warn in between the onChangeTab prop block.

I've fixed this scenario in my app by doing this.

sinhpn92 commented 5 years ago

I have same issue :( My info:

info 
  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
      Memory: 1.98 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.14.2 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.9.2 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.0, 28.0.0, 28.0.2, 28.0.3, 29.0.0, 29.0.0, 29.0.0, 29.0.0
        System Images: android-19 | ARM EABI v7a, android-19 | Intel x86 Atom, android-19 | Google APIs ARM EABI v7a, android-19 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.4 AI-183.6156.11.34.5522156
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.9 => 0.59.9 
    npmGlobalPackages:
      metro-react-native-babel-preset: 0.51.1
      react-native-cli: 2.0.1
      react-native-fast-image: 5.0.11
Al-JeMay commented 4 years ago

Actually yes the problem is with the onChangeTab make sure you have not put any console logs or console warn in between the onChangeTab prop block.

I've fixed this scenario in my app by doing this.

Thank You so much @Tracklous for this solution, it save me a lot of trouble.