Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScrollViewClass must not be undefined - react native iOS

I'm having an issue with ScrollViewClass being undefined but only in one location of the app and only for the iOS version in react-native.

ScrollView is used in multiple locations in the app and works fine but in this one particular part of the app, it results in an error screen stating that ScrollViewClass must not be undefined

ScrollViewClass must not be undefined

                    <ScrollView style={styles.descriptionContainer}
                            contentContainerStyle={styles.descriptionContainerInner}>
                    {/* The description text */}
                    <Text style={styles.descriptionText}>
                        {this.state.description}
                    </Text>
                </ScrollView>
like image 634
Michael Avatar asked Sep 24 '26 11:09

Michael


1 Answers

... Basically, there was a bad equality checker of:

if (Platform.OS = 'android') { ...

for

componentDidMount() {  
    if (Platform.OS === 'android') {
            BackAndroid.addEventListener('hardwareBackPress', this.handleBackOnOverlay);
    }

Which resulted in the event listener being added for the android back button in the iOS app. The above errors were showing as a result of this it seems. Never assume the error message is the error as such.

like image 191
Michael Avatar answered Sep 27 '26 02:09

Michael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!