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

Doesn't work in a ScrollView #187

Closed
sercanov opened this issue Mar 2, 2016 · 49 comments
Closed

Doesn't work in a ScrollView #187

sercanov opened this issue Mar 2, 2016 · 49 comments
Labels

Comments

@sercanov
Copy link

sercanov commented Mar 2, 2016

Tried in a normal View, works. But when I put ScrollableTabView component in a ScrollView ; it renders the tabs but not the child elements.

Using React Native 0.21 on Android

@skv-headless
Copy link
Collaborator

Could you please attach your code only part with react-native-scrollable-tab-view?

@sercanov
Copy link
Author

sercanov commented Mar 2, 2016

@skv-headless sure!

              <ScrollView style={{flex:1}}>
                <GuideBanner currentGuide = {this.state.currentGuide} isLoading={this.state.loading}  />
                <ScrollableTabView style={{flex:1}} initialPage={0}>
                  <ItemSegment tabLabel='Items' guideDetail={this.state.currentGuide}/>
                  <SkillSegment tabLabel='Skills' guideDetail={this.state.currentGuide}/>
                </ScrollableTabView>
              </ScrollView>

The code above doesn't render the child elements (ItemSegment and SkillSegment)

But when I add contentContainerStyle={{flex:1}} to the parent ScrollView; it renders the child elements but it allows to scroll only inside the tab view, not whole parent view.

@haikov
Copy link

haikov commented Mar 18, 2016

I'm facing the same issue. Doesn't render child element

@jbrodriguez
Copy link

Hi, same here, when it's inside a ScrollView, not only it doesn't render the child elements, but it doesn't allow tab selection, the bottom bar, moves just a bit, then jumps ... well, it's inconsistent behaviour

screenshot

@jiuxuan00
Copy link

Hi, same here, when it's inside a ScrollView, not only it doesn't render the child elements, but it doesn't allow tab selection, the bottom bar, moves just a bit, then jumps ... well, it's inconsistent behaviour
image

@punitlohani93
Copy link

Encountered this issue in Android. Works well on iOS. In android, if you press the tab long enough, only then, the tabs will switch. Nevertheless the tab content is not rendered in my case. No such issue in iOS

@sankhadeeproy007
Copy link

Hi any updates on this one? I'm getting the same error.

@martinezguillaume
Copy link

martinezguillaume commented May 19, 2016

Don't work in android, the child components don't render... on iOS no problem

@vince-rowe
Copy link

Same issue on react native 0.26.2 and latest install of scrollable tab view. As comments above we can get the contents to show on Android with either using a View that then won't scroll as needed, or by adding ContainerStyle={{flex:1}} to ScrollView which also stops the scroll.

Any update on a possible fix?

@SudoPlz
Copy link

SudoPlz commented Jun 14, 2016

I've got the same problem on React native 0.26.2 and the 0.4.4 version of react-native-scrollable-tab-view.

@ivpusic
Copy link

ivpusic commented Jun 21, 2016

same here

@gorangajic
Copy link

related? facebook/react-native#4775

@TLenahan
Copy link

TLenahan commented Jul 7, 2016

Is there any update on this issue? I'm running into the same problem.

@sckoh
Copy link

sckoh commented Jul 13, 2016

same prob on react-native 0.29

@jbrodriguez
Copy link

@skv-headless do you have any idea what the problem might be ?

It's still happening on 0.30

Is it facebook/react-native#4775 really ?

@jbrodriguez
Copy link

RN 0.31 brings this change, hopefully it solves the nested issue

facebook/react-native@b0c023c

@luiscript
Copy link

I'm using it with this Parallax scroll view and I'm having the same issue, child doesn't render and I can't scroll between tabs… Great work, I hope this can be solved. Thanks.

@jbrodriguez
Copy link

jbrodriguez commented Aug 5, 2016

It still doesn't work in 0.31 (Android) :(

As soon as you nest the ScrollableTabView inside a View/ScrollView, the tab contents are not shown.

It doesn't make a difference if you flex: 1 or not

(This is on a fresh react-native init)

import React, { Component } from 'react'
import { AppRegistry, StyleSheet, View, ScrollView, Text } from 'react-native'

import ScrollableTabView from 'react-native-scrollable-tab-view'

class Page extends Component {
    render() {
        return (
            <View style={{backgroundColor: 'blue'}}>
                <Text>{this.props.name}</Text>
            </View>
        )
    }
}

class app extends Component {
    render() {
        return (
            // <ScrollView>
            //  <View style={{height: 150}}>
            //      <Text>Testing</Text>
            //  </View>

            // <View>
                <ScrollableTabView>
                    <Page name='tab1' tabLabel='tab1' />
                    <Page name='tab2' tabLabel='tab2' />
                    <Page name='tab3'  tabLabel='tab3' />
                    <Page name='tab4' tabLabel='tab4' />
                    <Page name='tab5' tabLabel='tab5' />
                    <Page name='tab6' tabLabel='tab6' />
                </ScrollableTabView>
            // </View>
            // </ScrollView>
        )
    }
}

AppRegistry.registerComponent('app', () => app)

@jbrodriguez
Copy link

Well, it's not a react-native-scrollable-tab-view issue.

It's definitely a ViewPagerAndroid issue.

The example below won't work as soon as the ViewPagerAndroid is nested.

import React, { Component } from 'react'
import { AppRegistry, View, ViewPagerAndroid, Text } from 'react-native'

class app extends Component {
    constructor(props){
        super(props);
    }
    render(){
        return (
                // <View>
                    <ViewPagerAndroid
                        initialPage={0}
                    >
                        <View><Text>page1-1</Text></View>
                        <View><Text>page1-2</Text></View>
                        <View><Text>page1-3</Text></View>
                    </ViewPagerAndroid>
                // </View>
        )
    }
}

AppRegistry.registerComponent('app', () => app)

@jbrodriguez
Copy link

jbrodriguez commented Aug 5, 2016

I got it working with the following code

class Page extends Component {
    render() {
        return (
            <View style={{flex: 1, backgroundColor: 'blue'}}>
                <Text>{this.props.name}</Text>
            </View>
        )
    }
}

class app extends Component {
    render() {
        return (
            <ScrollView
                contentContainerStyle={{flex: 1}}
            >
                <View style={{flex: 1}}>
                    <ScrollableTabView>
                        <Page name='tab1' tabLabel='tab1' />
                        <Page name='tab2' tabLabel='tab2' />
                        <Page name='tab3' tabLabel='tab3' />
                        <Page name='tab4' tabLabel='tab4' />
                        <Page name='tab5' tabLabel='tab5' />
                        <Page name='tab6' tabLabel='tab6' />
                    </ScrollableTabView>
                </View>
            </ScrollView>
        )
    }
}

AppRegistry.registerComponent('app', () => app)

AND

removing Android specific code in the component, that is ... eliminating the use of ViewPagerAndroid (since it's so troublesome).

https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/index.js#L79
https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/index.js#L143

For the test, I changed those two lines to read if (Platform.OS === 'android') {, and it just worked !

So, the question for @skv-headless ... is there any special reason to use ViewPagerAndroid at all ?

@crozzfire
Copy link

crozzfire commented Aug 5, 2016

@jbrodriguez That actually works! But I wouldn't change it as: if (Platform.OS === 'android') { , because the support for iOS would disappear. Instead, I made the 'iOS' specific code as the main code and deleted the android specific code. Works like a charm and I guess the problem indeed is in ViewPagerAndroid.

@skv-headless If it doesn't seem like something way wrong, you might wanna consider it. Can send out a pull request.

@jbrodriguez
Copy link

@crozzfire I was forcing 'android' just as a proof of concept, but the right way would be a single path of execution, like you mentioned 👍

@chengmu
Copy link

chengmu commented Aug 23, 2016

@jbrodriguez @crozzfire tried this way, really works like a magic!!! Thanks, really helped a lot

@tioback
Copy link

tioback commented Sep 5, 2016

@crozzfire I tried this approach, but even though the content started showing and swiping is working, scrolling is not. Has anyone else had this problem?

walidvb added a commit to walidvb/react-native-scrollable-tab-view that referenced this issue Sep 29, 2016
@tiaaaa123
Copy link

@jbrodriguez Thank you so much!

@skv-headless Is PageViewerAndroid really necessary?

@summersky92
Copy link

summersky92 commented Oct 12, 2016

maybe it's fixed by this commit [(https://github.com/skv-headless/react-native-scrollable-tab-view/commit/5d8aeb1f8cc13cdfbb1bf75ea12866548f872edd)] @chromonav @tioback

@tioback
Copy link

tioback commented Oct 12, 2016

Thanks, @summersky92, I'll check it out later and post an update here.

@gotounix
Copy link

@tioback @skv-headless This commit 5d8aeb1 will make the sub ScrollablePage in ScrollablePage cannot be changed by sliding, and sliding just change the tab for parent.

@skv-headless
Copy link
Collaborator

@gotounix not sure what do you mean. Can you please make a snippet which doesn't work. Thanks

@gotounix
Copy link

gotounix commented Oct 28, 2016

@skv-headless I meaning if using this commit 5d8aeb1 when I embed a ScrollablePage (child) in a ScrollablePage (parent), translation fingers sliding can't switch tabs in child, translation fingers sliding just switch tabs in parent.

{/*This is the parent*/}
<ScrollableTabView
    renderTabBar={() => <BottomTabBar
        tabNames={bottomTabNames}
        tabIconNames={bottomTabIconNames} />}
        tabBarPosition='bottom'>
    <View style={styles.content}>
        <Text>#1</Text>
    </View>
    {/*This is the child and
    the ScrollablePage below can't switch tabs by translation fingers sliding*/}
    <ScrollablePage tabNames={aTabNames} />
</ScrollableTabView>

@boniattirodrigo
Copy link

I'm trying to add a parallax component around react-native-scrollable-tab-view, but I'm having the same issue. Did anyone resolve it?

@WillyRamirez
Copy link

Hi @skv-headless
What is the status of this? I still don't have child components when enclosing my component with a ScrollView... The solution jbrodriguez provided seems not to be valid anymore. I am using "0.6.5"

@prestawithme
Copy link

prestawithme commented May 19, 2017

For me, it does not relate to react-native-scrollable-tab-view. It related to the structure.

for my example (I'm using react native base):

Doesn't work code

class AnatomyExample extends Component {

    render() {

        return (

          <Container>

             <Header>

                 <Left>

                     <Button transparent>

                         <Icon name='menu' />

                     </Button>

                 </Left>

                 <Body>

                     <Title>Todo App</Title>

                 </Body>

                 <Right />

             </Header>

             <Content> 

             <ScrollTabView style={{flex: 1, backgroundColor: 'white'}}>

               <Todo tabLabel="Todo" />

               <Completed tabLabel="Completed" />

             </ScrollTabView>             

             </Content>

             <Footer>

                <Text>Input to add to do here</Text>

             </Footer>

         </Container>

        );
    }
}```



**Working code**

class AnatomyExample extends Component {

render() {

    return (

      <Container>

         <Header>

             <Left>

                 <Button transparent>

                     <Icon name='menu' />

                 </Button>

             </Left>

             <Body>

                 <Title>Todo App</Title>

             </Body>

             <Right />

         </Header>

         <ScrollTabView style={{flex: 1, backgroundColor: 'white'}}>

           <Todo tabLabel="Todo" />

           <Completed tabLabel="Completed" />

         </ScrollTabView>         

         <Footer>

            <Text>Input to add to do here</Text>

         </Footer>

     </Container>
    );
}

}```

@slaveofcode
Copy link

Hi what the status of this issue? because i'm facing the same issue by the way

@MaxiSantos
Copy link

@prestawithme, yes.. same here. I'm modifying the height of the container of the ScrollTabView and I'm seeing content. Basically this is not working on android but it looks you have achieved that. Can you provide all the styles you have used?

@anhnguyenvan-agilityio
Copy link

you can using this lib ! it fixed this bug
[https://github.com/turfaa/react-native-scrollable-tab-view-universal)]

@Toriki07
Copy link

thank you, it work for me

@VesperDev
Copy link

@anhnguyenvan this work.

only copy the code of file index.js to react-native-scrollable-tab-view

@rezaarifian
Copy link

I got it working with the following code

class Page extends Component {
    render() {
        return (
            <View style={{flex: 1, backgroundColor: 'blue'}}>
                <Text>{this.props.name}</Text>
            </View>
        )
    }
}

class app extends Component {
    render() {
        return (
            <ScrollView
                contentContainerStyle={{flex: 1}}
            >
                <View style={{flex: 1}}>
                    <ScrollableTabView>
                        <Page name='tab1' tabLabel='tab1' />
                        <Page name='tab2' tabLabel='tab2' />
                        <Page name='tab3' tabLabel='tab3' />
                        <Page name='tab4' tabLabel='tab4' />
                        <Page name='tab5' tabLabel='tab5' />
                        <Page name='tab6' tabLabel='tab6' />
                    </ScrollableTabView>
                </View>
            </ScrollView>
        )
    }
}

AppRegistry.registerComponent('app', () => app)

AND

removing Android specific code in the component, that is ... eliminating the use of ViewPagerAndroid (since it's so troublesome).

https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/index.js#L79
https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/index.js#L143

For the test, I changed those two lines to read if (Platform.OS === 'android') {, and it just worked !

So, the question for @skv-headless ... is there any special reason to use ViewPagerAndroid at all ?

thanks,
I following this commit

@spencerkingman-niche
Copy link

I am using https://github.com/turfaa/react-native-scrollable-tab-view-universal and it works like a dream. Is there any reason why this has to be a separate project? Or can the changes in this fork be incorporated into this project (Which is far more popular)?

@ptomasroos
Copy link
Owner

@spencerkingman-niche

This branch is 6 commits ahead, 11 commits behind.

Are there any significant changes in that repo?

@ptomasroos
Copy link
Owner

I've now chcked the fork out @spencerkingman-niche and I will incorporate the idea of replacing the PageView with a ScrollView instead on the next write which I'm doing at this moment in #949

Thanks for pointer

@spencerkingman-niche
Copy link

Thank you!

@turfaa
Copy link

turfaa commented Nov 28, 2018

@spencerkingman-niche @ptomasroos

Hi,
There is no significant update on my repo. Just changing the name, version, and readme explaining what has changed.

Why no pull request instead? Because it breaks in more cases. I forgot what are those cases, but it breaks. I thought the use of ViewPagerAndroid was intended because of those breaks.

Is it better to add a parameter, letting users to choose which one to use (ScrollView vs ViewPagerAndroid)?

@andyr6381
Copy link

andyr6381 commented Jan 26, 2019

Also got it to work with the fork package.json: "react-native-scrollable-tab-view": "git+https://github.com/turfaa/react-native-scrollable-tab-view-universal", and code below.

Only issue I have now is the scroll view sets whichever tab has the biggest height, hopefully find a way to set this dynamic. Any suggestions?

screenshot 2019-01-26 at 8 47 49 pm

@juliscotto
Copy link

@andyr6381 im having the same problem, did find a solution?

@eramudeep
Copy link

im having the same problem, did find a solution?
:(

@juliscotto
Copy link

@eramudeep couldnt find a solution, so I ended up using this with this approach, hope it helps!

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

No branches or pull requests