NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Rendering error on `Tabs` when `initialPage` is not `0`

Open bflatmajor opened this issue 9 years ago • 9 comments

react-native, react and native-base version

React Native: 0.48.4.

React: 16.0.0-alpha.12.

Native Base: 2.3.3.

Steps to reproduce (code snippet or screenshot)

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import {
    Container,
    Tabs,
    Tab,
} from 'native-base';

export default class App extends React.Component {
    render() {
        return (
            <Container>
                <Tabs initialPage={1}>
                    <Tab heading="Tab 1">
                        <Text>1</Text>
                    </Tab>
                    <Tab heading="Tab 2">
                        <Text>2</Text>
                    </Tab>
                    <Tab heading="Tab 3">
                        <Text>3</Text>
                    </Tab>
                </Tabs>
            </Container>
        );
    }
};

Result:

img_ca5acb1f7d9c-1

However, when I add a padding to the parent (<Container style={{paddingHorizontal: 10}}>), it works fine:

img_66f986ad364d-1

Is the bug present in both ios and android or in any one of them?

Both.

bflatmajor avatar Oct 21 '17 07:10 bflatmajor

I'm seeing the same thing with

    "react-native": "^0.48.4",
    "native-base": "^2.3.2",
    "react": "^16.0.0",

dtuite avatar Oct 21 '17 17:10 dtuite

Temporary workaround but it works (RN: 0.48): "expo": "^21.0.0", "moment": "^2.18.1", "native-base": "^2.3.2", "react-native": "https://github.com/expo/react-native/archive/sdk-21.0.2.tar.gz"

XXX = src/dist in node_modules/native-base/XXX/basic/tabs/index.js Replace:

if (this.scrollView && Platform.OS === "android") {
	const x = this.props.initialPage * this.state.containerWidth;
	this.scrollView.scrollTo({ x, animated: false });
}

with:

if (this.scrollView) {
	const x = this.props.initialPage * this.state.containerWidth;
	this.scrollView.scrollTo({ x, animated: false });
}

ziudeso avatar Oct 22 '17 12:10 ziudeso

@ziudeso solution helps with selecting correct tab, but my problems is that the view is not drawn, and I have to touch and move the screen before data in Tab is visible (initial load only). Tabs are nested in a TabNavigator, and they are the second tab in TabNavigator

"@expo/samples": "^2.0.2", "expo": "^22.0.0", "moment": "^2.19.1", "native-base": "^2.3.2", "react": "16.0.0-beta.5", "react-native": "https://github.com/expo/react-native/archive/sdk-22.0.1.tar.gz", "react-navigation": "^1.0.0-beta.15", "react-redux": "^5.0.6", "redux": "^3.7.2",

lazy: true on the TabNavigator is a temporary fix to this issue

Is the bug present in both ios and android or in any one of them? Only IOS

Sigve84 avatar Oct 30 '17 15:10 Sigve84

#1010

SupriyaKalghatgi avatar Nov 09 '17 11:11 SupriyaKalghatgi

i have issue related to Tabs. Can u help me??

vijaya06 avatar Feb 19 '18 12:02 vijaya06

@vijaya06 What is it

SupriyaKalghatgi avatar Feb 19 '18 12:02 SupriyaKalghatgi

@vijaya06 Check for Tabs issues, if you could get any help from it Else go ahead and raise issue

SupriyaKalghatgi avatar Feb 19 '18 12:02 SupriyaKalghatgi

This issue is not fixed in native-base version 2.3.10.

hanssonfredrik avatar Mar 10 '18 20:03 hanssonfredrik

Same here for [email protected] and [email protected]

yaronlevi avatar Mar 18 '18 07:03 yaronlevi