简体   繁体   English

访问 react-select 中的内部输入元素

[英]access to inner input element in react-select

there is an script out there called farsitype.js and i want to use it with react-select component but there is no way to direct access to inner input field to add attribute to it.有一个名为 farsitype.js 的脚本,我想将它与 react-select 组件一起使用,但无法直接访问内部输入字段以向其添加属性。 is there any way that we can add attributes to inner input field in react-select?有什么方法可以在 react-select 中向内部输入字段添加属性?

If you are talking about this react-select library.如果你在谈论这个react-select库。 You can customize the Input component like so:您可以像这样自定义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}
  />
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM