javascript - 强制 RTL 的 NativeBase 选项卡问题 - 修复

标签 javascript react-native native-base

当我执行 forceRtl 时,我遇到了原生基本选项卡的问题。一切正常,但只有 native 基础在初始加载时不显示任何内容。

所以我有一个临时解决方案

最佳答案

在 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>
        );
        },

不要忘记更改 package.json 中的 "main": "src/index.js"

关于javascript - 强制 RTL 的 NativeBase 选项卡问题 - 修复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58736619/

相关文章:

css - 如何在 flexbox 中将内容对齐到中心

android - express 端口 3000,react native 端口 8081,如何发出 get 请求

javascript - 动态水平滚动

javascript - 如何在页面加载时启动 Phonegap 自定义对话框?

javascript - Canvas 和舞台在画架.js 中失去全局范围

android - react native ffmpeg : Native module cannot be null (ios) and null is not an object (evaluating 'RNFFmpegModule.enableLogEvents' ) (android)

android - 在某些 Android 设备中,图像无法在 FlatList 上呈现

android - 基本的 react native 应用程序不显示任何文本,仅在模拟器上显示带有应用程序名称的白屏

javascript - 我无法从我的 javascript 函数获取返回码

javascript - React Native 错误 - React : createElement: type should not be null