I'm building React Native app with Expo. It works fine on my Android device via Expo application. But I have the error after I've built apk via exp build:android command.
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
Problem is inside ScrollView. It is gone if I remove ScrollView. Here is my code snippet.
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,
},
});
This bug is caused by uglify-es 3.3.X
which is used when building a release version.
Add this block to your package.json:
"resolutions": {
"uglify-es": "3.2.2"
}
I tried both publishing on Expo and building a standalone app and it's working like a charm now.
Had same issue. Way to resolve this:
change
this._subscribableSubscriptions.forEach(
to
this._subscribableSubscriptions && this._subscribableSubscriptions.forEach(
in that file:
YOUR_PROJECT/node_modules/react-native/Libraries/Components/Subscribable.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With