在我的placeholderTextColor中,标题的错误仍然存在,并且没有找到解决方案
import React from 'react';
import { TextInputProps } from 'react-native';
import { color } from 'react-native-reanimated';
import { Container, TextInput, Icon } from './styles';
interface InputProps extends TextInputProps {
name: string;
icon: string;
}
// todas as propriedades "rest" sao passadas para o TExt Input, no caso apenas o placeholder
const Input: React.FC<InputProps> = ({ name, icon, ...placeholder }) => (
<Container>
<Icon name={icon} size={20} color="#666360" />
<TextInput
keyboardAppearance="dark"
placeholderTextColor="#666360"
{...placeholder}
/>
</Container>
);
export default Input;
错误仍然存在,如果我删除了扩散运算符,错误就会消失,但这不是解决方案。
完全错误
(JSX属性) placeholderTextColor?:string | typeof OpaqueColorValue |未定义占位符字符串的文本颜色
没有与此调用匹配的重载。重载1/ 2,‘(属性: Pick & Partial<...>,"ref“| ... 109 more ... | "showSoftInputOnFocus"> &{ ...;}):ReactElement<...>’给出了以下错误。类型'ColorValue‘不可赋值给类型’字符串|唯一符号|未定义‘。不能将类型'unique symbol‘赋值给类型'string | unique symbol | undefined’。重载2个,‘(属性: StyledComponentPropsWithAs):新的TextInput,DefaultTheme,{},never>,string | ... 1更多... |(StyledComponentPropsWithAs Component<...>)>',给出了以下错误。类型'ColorValue‘不可赋值给类型’字符串|唯一符号|未定义‘。类型'unique symbol‘不能赋值给类型'string | unique symbol |undefined’。to (2769) index.d.ts(1626,5):期望的类型来自属性'placeholderTextColor‘,它在类型'IntrinsicAttributes & Pick & Partial<...>,"ref”| ... 109 more ... | "showSoftInputOnFocus"> &{ ...;}&{ ...;}&{ ...;}‘index.d.ts(1626,5):预期的类型来自属性'placeholderTextColor’,它在此处的类型'IntrinsicAttributes & Pick & Partial<...>,"ref”| ... 109 more ...‘上声明
发布于 2020-12-01 03:38:01
这种情况的解决方案是接收属性导入内部的其他属性占位符,如下所示:
interface InputProps extends TextInputProps {
name: string;
icon: string;
placeholder: string;
}
// todas as propriedades "rest" sao passadas para o TExt Input, no caso apenas o placeholder
const Input: React.FC<InputProps> = ({ name, icon, placeholder }) => (
<Container>
<Icon name={icon} size={20} color="#666360" />
<TextInput keyboardAppearance="dark" placeholder={placeholder} />
</Container>
);
export default Input;
Thx @Someone专门找出样式组件的问题
https://stackoverflow.com/questions/65075691
复制相似问题