ios - 向本机 ios 组件提供道具时出现“不必要”的 TS 问题
问题描述
我使用 Swift 创建了一个名为 CounterView 的本机模块,当我这样使用它时:
<CounterView style={{flex: 1}} />
我收到了这个讨厌的警告!但问题是,一切正常。如果我删除样式道具,错误就会消失,但如果没有 {flex: 1},则不会呈现任何内容。所以我试图将它包装在一个视图中,但随后它相对于整个屏幕而不是包装器呈现。我怎样才能摆脱这个错误?我做错了什么使我的组件“只读”吗?
Type '{ style: { flex: number; }; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<unknown, {}, any> & Readonly<NativeMethods>> & Readonly<...> & Readonly<...>'.
Property 'style' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<unknown, {}, any> & Readonly<NativeMethods>> & Readonly<...> & Readonly<...>'.
如果我这样做,我可以绕过这个问题:
<View style={{flex: 1}}>
<View style={{flex: 1}} />
<View style={{flex: 1}}>
<CounterView />
</View>
</View>
这会处理将被另一个 flex:1 容器占用的另一半屏幕,但这看起来很傻。
解决方案
推荐阅读
- web-services - IIS 管理器 - 无法启动 W3SVC 并且服务中缺少 IIS 管理员
- html - Outlook 中未继承行高
- r - 如何防止代码检测和提取单词中的模式(例如:我希望在单词 al'one' 中检测到 'one' 而不是 'one')?
- powershell - Powershell命令在数组中向前和向后移动
- jquery - 点击时停止 setInterval
- xmlstarlet - 使用 xmlstarlet 选择不包含特定子节点的节点
- asp.net-mvc - 如何格式化来自自定义验证器的错误消息
- azure-functions - 是否可以将 Azure 功能转换为 Azure webjob
- chisel - 使用动态索引时如何显示我的电汇名称?
- watson-knowledge-studio - WEX 的输出是否支持基于 WKS 上下文的实体类型角色?