Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggling tabs not working after poping back in Android #839

Closed
AndrewJikun opened this issue Feb 11, 2018 · 14 comments
Closed

Toggling tabs not working after poping back in Android #839

AndrewJikun opened this issue Feb 11, 2018 · 14 comments

Comments

@AndrewJikun
Copy link

AndrewJikun commented Feb 11, 2018

I have a react-native-scrollable-tab-view working well in screen A and then push to screen B. In Screen B I do nothing and pop back to screen A. then in Screen A I can not toggle tabs in Screen A any more. It works well in IOS but bad in Android.

@AndrewJikun
Copy link
Author

react-native-scrollable-tab-view version: 0.8.0. React native version:0.51

@AndrewJikun
Copy link
Author

AndrewJikun commented Feb 13, 2018

@skv-headless could you please fix it?

@oankarberg
Copy link

+1

5 similar comments
@fpauer
Copy link

fpauer commented Feb 22, 2018

+1

@zerotalk
Copy link

+1

@dylanslade
Copy link

+1

@lukaleli
Copy link

lukaleli commented Mar 6, 2018

+1

@jenswellmeyer
Copy link

+1

@jenswellmeyer
Copy link

Should be related to this:
facebook/react-native#14867

@fpauer
Copy link

fpauer commented Mar 6, 2018

Hey Guys,

I solved my problem setting style flex to 1 when component is visible. We use react-native-navigation, so we implemented setOnNavigatorEvent to detect when the component is visible or not.

  constructor(props) {
    super(props);
      this.state = {
        contentProps: {
          style: { flex: 1 }
        }
      }; 
      this.props.navigator.setOnNavigatorEvent(this.onNavigatorEvent.bind(this));
   }
  
onNavigatorEvent(event) {
    switch (event.id) {
      case 'willAppear':
        this.setState({contentProps: {style: { flex: 1}}});
        break;
      case 'willDisappear':
        this.setState({contentProps: {style: { flex: 0}}});
        break;
    }
 }

<ScrollableTabView
        contentProps={this.state.contentProps}
>

Why ?

There is a bug for viewPagerAndroid when navigation goes back to previous screen after pushes a new one, it does not trigger onLayout again and the component does not re-render. As it was suggested in these threads below to reinforce layout state by changing flex style when the screen is visible or not.

wix/react-native-navigation#1317
#684

@Tritty
Copy link

Tritty commented Mar 9, 2018

@fpauer Perfect. It works for me! Thank you so much!

@kubilaytural
Copy link

@fpauer Thank's. I works for me!

@harrydema
Copy link

@fpauer Can you please show the full class? As my event is not fired. I am passing the navigator through props to the child screens.

@theRedster
Copy link

#797

This will probably fix it for most people.

find the index.js in node_modules/react-scrollable-tab-view and replace the contents. Fixed it for me and works with ios and android still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests