typescript - react-color 库是否在 react-native typescript 中工作
问题描述
我使用 yarn add @types/react-color 添加了包,这是我的组件代码
const ColorPicker: React.FC = () => {
const [background, setBackground] = useState<string>('#fff');
const handleChangeComplete = (
color: ColorResult,
) => {
setBackground(color.hex);
};
return (
<Modal
animationType="fade"
transparent
visible={true}
presentationStyle="overFullScreen">
<View
style={{
flex: 1,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.2)',
}}>
<View style={{width: '95%', backgroundColor: '#fff', borderRadius: 7}}>
<SketchPicker
color={background}
onChangeComplete={handleChangeComplete}
/>
</View>
</View>
</Modal>
);
};
export default ColorPicker;
我有一个按钮,单击时会显示这样的颜色选择器组件
{showPicker && <ColorPicker />}
当我点击按钮时,虽然我看到了这个错误!
Invariant Violation: View config getter callback for component `div` must be a function (received `undefined`). Make sure to start component names with a capital letter.```
解决方案
推荐阅读
- sql - 在更新该选择的字段时插入选择
- javascript - 在 c# 中使用 javascript 数组填充剃刀表
- ios - 如何在拆分视图的详细信息区域限制MessageKit的输入栏
- grails - Grails 升级 - 1.3.7 到 2.4.1 以兼容 Java 1.8。如何在类路径中添加自定义 jar
- flyway - 是否 Flyway 工具支持 Oracle E-Business Suite 中的 .rdf、.rtf、.xml、.pks、.pkb 等扩展名 --> 财务管理
- javascript - 从 jQuery 运行 PHP 脚本,然后提交表单
- node.js - 直接使用 chromedriver 运行 webdriver.io,而不是使用 selenium 服务器
- php - 登录后,如何在 laravel 中使用 ajax post 请求?
- apache - odoo 11 在端口 8069 上被谷歌索引
- ios - Swift 中 JTAppleCalendar 中日期标签下的月份名称