[英]React select custom input won't hide placeholder
I am following the React Select docs to alter the Input component of the Select (to add more properties I need to the default input:我正在按照 React Select 文档更改 Select 的输入组件(为默认输入添加我需要的更多属性:
const Input = ({ innerProps }) => {
return <input {...innerProps} {...somethingElseINeed} />;
};
const CustomSelect = props => {
return (
<Select components={{ Input }}></Select>
);
};
It does add a custom input, however it:它确实添加了自定义输入,但是它:
I tried to use getStyled
and theme
properties that shoold come by default, but no luck.我尝试使用默认设置的
getStyled
和theme
属性,但没有成功。
Any idea what I am missing?知道我错过了什么吗?
1) 1)
What about aria props, you can get it from input props, that has appropriate view aria props 怎么样,你可以从 input props 中得到它,有适当的视图
2) 2)
if you look at react-select components tree you will see that RS paste placeholder into another component如果您查看 react-select 组件树,您会看到 RS 将占位符粘贴到另一个组件中
and you can remove placeholder on focus like that just add styles with using state:您可以删除焦点上的占位符,就像使用 state 添加 styles 一样:
const styles = {
placeholder(base, state) {
return {
...base,
display: state.isFocused && 'none',
};
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.