NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

refreshControl in tab

Open Martin25699 opened this issue 9 years ago • 13 comments

Hello, after add package (zo0r/react-native-push-notification or facebook/react-native-fbsdk) loading wheel hangs on the swipe Version

"dependencies": {
		"native-base": "^2.3.1",
		"react": "16.0.0-alpha.12",
		"react-native": "0.47.1",
		"react-native-push-notification": "^3.0.0"
	}

Code page

import React, { Component } from 'react';
import { AppRegistry, RefreshControl } from 'react-native'
import { Container, Header, Content, Tab, Tabs } from 'native-base';
export default class AwesomeNativeBase extends Component {
    constructor(props) {
        super(props);
        this.state = {
            refreshing: false
        };
    }
    updateContent() {
        this.setState({refreshing:true});
        setTimeout(()=>{
            this.setState({refreshing:false});
        },2000);
    }
    render() {
        return (
            <Container>
                <Header hasTabs />
                <Tabs initialPage={1}>
                    <Tab heading="Tab1">
                        <Content refreshControl={<RefreshControl
                            refreshing={this.state.refreshing}
                            onRefresh={()=>{this.updateContent()}}/>
                        }>
                        </Content>
                    </Tab>
                    <Tab heading="Tab2">
                        <Content refreshControl={<RefreshControl
                            refreshing={this.state.refreshing}
                            onRefresh={()=>{this.updateContent()}}/>
                        }>
                        </Content>
                    </Tab>
                    <Tab heading="Tab3">
                        <Content refreshControl={<RefreshControl
                            refreshing={this.state.refreshing}
                            onRefresh={()=>{this.updateContent()}}/>
                        }>
                        </Content>
                    </Tab>
                </Tabs>
            </Container>
        );
    }
}
AppRegistry.registerComponent('AwesomeNativeBase', () => AwesomeNativeBase);

tab_bah

Martin25699 avatar Aug 16 '17 12:08 Martin25699

It's because you drag the tab into another tab while pulling the refresh trigger down. My workaround is to disable the sliding part or if you insist of doing the sliding refresh, you must check react-native-tab-view.

sitompul avatar Aug 18 '17 10:08 sitompul

@Martin25699 As @sitompul said, you are trying to change the Tabs while the refresh is triggered of one page, and both the Tabs have their own refresh functions. You can either lock the swipe functionality or use onChangeTab prop function and page prop to detect and trigger the refresh of the changed tab on swipe

shivrajkumar avatar Sep 11 '17 10:09 shivrajkumar

@shivrajkumar this problem does not occur if these packages are not installed (zo0r / react-native-push-notification or facebook / react-native-fbsdk), as I wrote above. Can error somewhere else?

Martin25699 avatar Sep 22 '17 11:09 Martin25699

@Martin25699 Do you have any handles of those packages being called while changing the tab?

shivrajkumar avatar Sep 28 '17 12:09 shivrajkumar

@shivrajkumar No, these packages are only connected to the project, and made react-native link. In this example, they are not needed, but are needed on the project, where the error is repeated.

Martin25699 avatar Oct 06 '17 17:10 Martin25699

@Martin25699 tried your example without react-native-push-notification. Did not feel like the issue is with the package. You can try shivraj's suggestion. Let us know if you face any issues.

akhil-ga avatar Nov 10 '17 07:11 akhil-ga

Closing the issue due to no response

akhil-ga avatar Nov 20 '17 06:11 akhil-ga

Same issue. I do not have react-native-push-notification nor react-native-fbsdk packages. It's impossible to have refreshcontrol with tabs.. Each time you try to to pull to refresh you automatically swipe :-(

camel113 avatar Jan 22 '18 19:01 camel113

@camel113 please use react-native-tab-view to handle your refreshissue

sitompul avatar Jan 23 '18 03:01 sitompul

Same problem, any responses to this issue ?

lmichailian avatar Mar 09 '18 19:03 lmichailian

@lmichailian the only fix is using react-native-tab-view

sitompul avatar Mar 12 '18 03:03 sitompul

@sitompul another lib, sad ... :(

lmichailian avatar Mar 12 '18 16:03 lmichailian

react-native-tab-view doesn't have dynamic width on each tab, but your tabs can handle that. So anyone was resolve this?

never00miss avatar May 17 '18 17:05 never00miss