Skip to content Skip to sidebar Skip to footer

Nativebase Tabs Issue For Force Rtl - Fix

I had problem with native base tabs when I did forceRtl. Everything works but only native base doesn't show anything on initial load . So I had a temporary solution

Solution 1:

In native-base/src/basic/Tabs/index.js

import { I18nManager } from "react-native"
       renderScrollableContent() {
        const scenes = this._composeScenes();
        const isRTLAndroid = I18nManager.isRTL;

        return (
          <ScrollView
            horizontal
            pagingEnabled
            automaticallyAdjustContentInsets={false}
            keyboardShouldPersistTaps="handled"
            contentOffset={{
              x: this.props.initialPage * this.state.containerWidth
            }}
            ref={scrollView => {
              this.scrollView = scrollView;
            }}
            onScroll={e => {
              const offsetX = e.nativeEvent.contentOffset.x;
              this._updateScrollValue(offsetX / this.state.containerWidth);
            }}
            onMomentumScrollBegin={this._onMomentumScrollBeginAndEnd}
            onMomentumScrollEnd={this._onMomentumScrollBeginAndEnd}
            scrollEventThrottle={16}
            scrollsToTop={false}
            showsHorizontalScrollIndicator={false}
            scrollEnabled={!this.props.locked}
            directionalLockEnabled
            alwaysBounceVertical={false}
            keyboardDismissMode="on-drag"
            {...this.props.contentProps}
          >
          /*******************************************
            If is isRtl do reverse else keep as it is
          ********************************************/
            {isRTLAndroid?scenes.reverse():scenes}
          </ScrollView>
        );
        },

Don't forget to change "main": "src/index.js" in package.json

Post a Comment for "Nativebase Tabs Issue For Force Rtl - Fix"