react-native – React Native ScrollView TypeError:undefined不是对象(评估’this._subscribableSubscriptions.forEach’)

前端之家收集整理的这篇文章主要介绍了react-native – React Native ScrollView TypeError:undefined不是对象(评估’this._subscribableSubscriptions.forEach’)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Expo构建React Native应用程序.它通过Expo应用程序在我的 Android设备上运行良好.但是我通过exp build:android命令构建了apk后出现错误.
TypeError: undefined is not an object (evaluating 'this._subscribableSubscriptions.forEach')                                                  
This error is located at:
  in ScrollView
  in RCTView
  in r
  in Connect(r)
  in n
  in t
  in r
  in RCTView
  in RCTView
  in t

问题出在ScrollView中.如果我删除ScrollView,它就消失了.这是我的代码片段.

class Main extends Component {
state = {
    refreshing: false
};

renderCurrencies() {
    if (!Object.values(this.props.currencies).length) {
        return <View />;
    }

    return Object.values(this.props.currencies).map(item => {
        return (
            <CurrencyRow
                key={item.code}
                code={item.code}
                title={item.title}
            />
        );
    });
}

onRefresh = () => {
    Object.values(this.props.currencies).map(item => {
        this.props.sellBuyFetch(item.code);
    });
};

render() {
    return (
        <View style={styles.container}>
            <ScrollView
                refreshControl={
                    <RefreshControl
                        refreshing={this.state.refreshing}
                        onRefresh={this.onRefresh}
                    />
                }
            >
                {this.renderCurrencies()}
            </ScrollView>
        </View>
    );
}
}

const styles = StyleSheet.create({
container: {
    flex: 1,marginTop: 40,},});
错误是由构建发布版本时使用的uglify-es 3.3.X引起的.

将此块添加到package.json:

“决议”:{
“uglify-es”:“3.2.2”
}

我尝试在Expo上发布并构建一个独立的应用程序,它现在就像一个魅力.

猜你在找的React相关文章