react-nativemultiple-choice

TypeError: Super expression must either be null or a function when trying to create a simple multple-choice in React-Native


I am trying to create a simple multiple choice like that

'

use strict';

import React, {
    Component,
    StyleSheet,
    Text,
    View
} from 'react-native';

import MultipleChoice from 'rn-multiple-choice'

class Home extends Component {
    render() {
        return (
            <View style={styles.container}>
                <MultipleChoice
                    options={[
                        'Lorem ipsum dolor sit',
                        'Lorem ipsum',
                        'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.',
                        'Lorem ipsum dolor sit amet, consetetur',
                        'Lorem ipsum dolor'
                        ]}
                    selectedOptions={['Lorem ipsum']}
                    maxSelectedOptions={2}
                    onSelection={(option)=>alert(option + ' was selected!')}
                />
            </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        marginTop: 60,
        margin: 20
    },
});

export default Home

But it gives me this erorr when I try to run it : TypeError: Super expression must either be null or a function

Somebody has any idea what the problem could be ?


Solution

  • You cannot import React from react native, and Component as well, you can only

    import React from 'react'
    

    and as well do this

    import React, { Component } from 'react';
    

    React and React-native are separate imports.