访问 react-select 中的内部输入元素
access to inner input element in react-select
那里有一个名为 farsitype.js 的脚本,我想将它与 react-select 组件一起使用,但无法直接访问内部输入字段以向其添加属性。有什么方法可以在 react-select?
中向内部输入字段添加属性
如果您在谈论这个 react-select 库。您可以像这样自定义 Input
组件:
import React from 'react';
import Select, { components } from 'react-select';
import { typeOptions } from '../data';
const Input = props => {
// add attribues to the component below
return <components.Input {...props} />;
};
export default () => (
<Select
components={{ Input }}
options={typeOptions}
/>
);
那里有一个名为 farsitype.js 的脚本,我想将它与 react-select 组件一起使用,但无法直接访问内部输入字段以向其添加属性。有什么方法可以在 react-select?
中向内部输入字段添加属性如果您在谈论这个 react-select 库。您可以像这样自定义 Input
组件:
import React from 'react';
import Select, { components } from 'react-select';
import { typeOptions } from '../data';
const Input = props => {
// add attribues to the component below
return <components.Input {...props} />;
};
export default () => (
<Select
components={{ Input }}
options={typeOptions}
/>
);