File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,6 @@ export type SelectProps<ValueType extends DefaultValueType = DefaultValueType> =
75
75
ValueType
76
76
> ;
77
77
78
- Select . displayName = 'Select' ;
78
+ ( Select as any ) . displayName = 'Select' ;
79
79
80
80
export default Select ;
Original file line number Diff line number Diff line change @@ -852,12 +852,32 @@ export default function generateSelector<
852
852
type RefSelectFuncType = typeof RefSelectFunc ;
853
853
const RefSelect = ( ( React . forwardRef as unknown ) as RefSelectFuncType ) ( Select ) ;
854
854
855
+ /**
856
+ * Typescript not support generic with function component,
857
+ * we have to wrap an class component to handle this.
858
+ */
859
+ class ClassSelect < VT > extends React . Component < SelectProps < OptionsType , VT > > {
860
+ selectRef = React . createRef < RefSelectProps > ( ) ;
861
+
862
+ focus = ( ) => {
863
+ this . selectRef . current . focus ( ) ;
864
+ } ;
865
+
866
+ blur = ( ) => {
867
+ this . selectRef . current . blur ( ) ;
868
+ } ;
869
+
870
+ render ( ) {
871
+ return < RefSelect ref = { this . selectRef } { ...this . props } /> ;
872
+ }
873
+ }
874
+
855
875
// Inject static props
856
876
if ( staticProps ) {
857
877
Object . keys ( staticProps ) . forEach ( prop => {
858
- RefSelect [ prop ] = staticProps [ prop ] ;
878
+ ClassSelect [ prop ] = staticProps [ prop ] ;
859
879
} ) ;
860
880
}
861
881
862
- return RefSelect as ( typeof RefSelect & StaticProps ) ;
882
+ return ClassSelect as ( typeof ClassSelect & StaticProps ) ;
863
883
}
You can’t perform that action at this time.
0 commit comments