我正试图使用材料ui中的复选框,但我不知道为什么我会收到不变错误消息
错误:
Invariant Violation: View config getter callback for component `path` must be a function (received `undefined`).
Make sure to start component names with a capital letter.
以下是我的代码:
import React from 'react';
import {View,Text,} from 'react-native';
import Checkbox from '@material-ui/core/Checkbox';
export default class App extends React.Component {
constructor() {
super();
this.state = { tick: false };
this.checkTick = this.checkTick.bind(this);
}
checkTick() {
this.setState({ tick: !this.state.tick });
}
render() {
return (
<View style={{ alignItems: "center" }}>
<Text>Hello</Text>
<View>
<Checkbox
checked={this.state.tick}
onPress={this.checkTick}
color="primary"
inputProps={{ 'aria-label': 'secondary checkbox' }}
/>
</View>
</View>
);
}
};
如果我使用react-native-elements
中的复选框,则不会出现此错误。但我想使用材料UI 中的复选框
material-ui
包适用于ReactJS web,而不适用于React Native。您不能将此包与React Native一起使用。