Ald*_*ldo 5 javascript typescript reactjs react-select
我正在使用 TypeScript 开发一个 React 项目。他们将react-select组件包装到另一个组件中。包裹的组件如下:
import * as React from "react";
import Select from "react-select";
import { Props as SelectProps } from "react-select/lib/Select";
export interface SelectValue {
label: string;
value: string;
}
export interface SelectFieldProps<TValue> extends SelectProps<TValue> {
label?: string;
}
type GenericSelectField<TValue> = React.StatelessComponent<
SelectFieldProps<TValue>
>;
const SelectField: GenericSelectField<SelectValue> = ({
label = "",
...rest
}) => (
<div className="react-select-wrapper">
{label ? <span className="input__label">{label}</span> : null}
<Select classNamePrefix="react-select" {...rest} />
</div>
);
export default SelectField;
Run Code Online (Sandbox Code Playgroud)
我想blur从 react-select访问该方法:
React-select 公开了两个公共方法:
...
blur() - 以编程方式模糊控件
但是,我不知道如何在我的组件中公开它,所以我可以调用它。有任何想法吗?
| 归档时间: |
|
| 查看次数: |
903 次 |
| 最近记录: |