ant-design/components/auto-complete/InputElement.tsx

26 lines
531 B
TypeScript
Raw Normal View History

import * as React from 'react';
export interface InputElementProps {
2019-06-24 11:29:58 +08:00
children: React.ReactElement<any>;
}
export default class InputElement extends React.Component<InputElementProps, any> {
saveRef = (ele: HTMLInputElement) => {
const { ref: childRef } = this.props.children as any;
if (typeof childRef === 'function') {
childRef(ele);
}
2018-12-07 16:17:45 +08:00
};
render() {
2018-12-07 16:17:45 +08:00
return React.cloneElement(
this.props.children,
{
...this.props,
ref: this.saveRef,
},
null,
);
}
}