TypeError: Super expression must either be null or a function when trying to create a simple multple-choice in React-Native
TypeError: Super expression must either be null or a function when trying to create a simple multple-choice in React-Native
我正在尝试创建一个简单的多项选择
'
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
但是当我尝试 运行 它时它给了我这个错误:TypeError: Super expression must either be null or a function
有人知道问题出在哪里吗?
不能从react native导入React,Component也不能,只能
import React from 'react'
也这样做
import React, { Component } from 'react';
React 和 React-native 是单独导入的。
我正在尝试创建一个简单的多项选择
'
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
但是当我尝试 运行 它时它给了我这个错误:TypeError: Super expression must either be null or a function
有人知道问题出在哪里吗?
不能从react native导入React,Component也不能,只能
import React from 'react'
也这样做
import React, { Component } from 'react';
React 和 React-native 是单独导入的。