react-native - 使用 Material UI 中的复选框时反应本机的不变违规
问题描述
我正在尝试使用来自 material-ui 的 Checkbox,但我不知道为什么我会收到 Invariant 错误消息
错误:
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>
);
}
};
如果我使用 CheckBox from react-native-elements
,那么我不会收到此错误。但我想使用 Material UI 中的 Checkbox
解决方案
该material-ui
软件包适用于 ReactJS web,而不适用于 React Native。你不能将此包与 React Native 一起使用。
推荐阅读
- python - PyGame 蛇游戏未在 PyCharm 中运行
- javascript - 当前版本的 Google Charts (v49) 打破了我的 google sheet table 可视化,而 v48 工作正常。为什么?
- javascript - 在函数中传递模板文字时遇到问题
- cucumber - 在黄瓜的示例表中使用数据表
- java - 您如何使用 reassured 将整个 Json 文件与其响应进行比较?
- java - Java 编辑文本文件的最佳和最快方式
- ios - 没有情节提要的应用程序启动 - UIViewController 仍然不可见
- c++ - C++ 优化器:除法
- go - GoLang 中的内置类型(或未定义类型)是什么?
- python - ValueError 长度不匹配 预期轴有 2 个元素,新值有 3 个元素