Skip to content

Commit c01fe37

Browse files
authored
chore: add NODE_ENV to displayName (#1008)
1 parent 92a7445 commit c01fe37

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

src/OptionList.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,9 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
395395
};
396396

397397
const RefOptionList = React.forwardRef(OptionList);
398-
RefOptionList.displayName = 'OptionList';
398+
399+
if (process.env.NODE_ENV !== 'production') {
400+
RefOptionList.displayName = 'OptionList';
401+
}
399402

400403
export default RefOptionList;

src/SelectTrigger.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export interface SelectTriggerProps {
7979
onPopupMouseEnter: () => void;
8080
}
8181

82-
const SelectTrigger: React.RefForwardingComponent<RefTriggerProps, SelectTriggerProps> = (
82+
const SelectTrigger: React.ForwardRefRenderFunction<RefTriggerProps, SelectTriggerProps> = (
8383
props,
8484
ref,
8585
) => {
@@ -180,6 +180,9 @@ const SelectTrigger: React.RefForwardingComponent<RefTriggerProps, SelectTrigger
180180
};
181181

182182
const RefSelectTrigger = React.forwardRef<RefTriggerProps, SelectTriggerProps>(SelectTrigger);
183-
RefSelectTrigger.displayName = 'SelectTrigger';
183+
184+
if (process.env.NODE_ENV !== 'production') {
185+
RefSelectTrigger.displayName = 'SelectTrigger';
186+
}
184187

185188
export default RefSelectTrigger;

src/Selector/Input.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ interface InputProps {
3333
>;
3434
}
3535

36-
const Input: React.RefForwardingComponent<InputRef, InputProps> = (
36+
const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (
3737
{
3838
prefixCls,
3939
id,
@@ -141,6 +141,9 @@ const Input: React.RefForwardingComponent<InputRef, InputProps> = (
141141
};
142142

143143
const RefInput = React.forwardRef<InputRef, InputProps>(Input);
144-
RefInput.displayName = 'Input';
144+
145+
if (process.env.NODE_ENV !== 'production') {
146+
RefInput.displayName = 'Input';
147+
}
145148

146149
export default RefInput;

src/Selector/SingleSelector.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,11 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
6666
if (item) {
6767
return null;
6868
}
69-
const hiddenStyle = hasTextInput ? { visibility: 'hidden' } as React.CSSProperties : undefined;
69+
const hiddenStyle = hasTextInput
70+
? ({ visibility: 'hidden' } as React.CSSProperties)
71+
: undefined;
7072
return (
71-
<span
72-
className={`${prefixCls}-selection-placeholder`}
73-
style={hiddenStyle}
74-
>
73+
<span className={`${prefixCls}-selection-placeholder`} style={hiddenStyle}>
7574
{placeholder}
7675
</span>
7776
);
@@ -108,14 +107,14 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
108107
</span>
109108

110109
{/* Display value */}
111-
{(!combobox && item) ? (
110+
{!combobox && item ? (
112111
<span
113112
className={`${prefixCls}-selection-item`}
114113
title={selectionTitle}
115114
// 当 Select 已经选中选项时,还需 selection 隐藏但留在原地占位
116115
// https://github.com/ant-design/ant-design/issues/27688
117116
// https://github.com/ant-design/ant-design/issues/41530
118-
style={hasTextInput ? { visibility: 'hidden' } as React.CSSProperties : undefined}
117+
style={hasTextInput ? ({ visibility: 'hidden' } as React.CSSProperties) : undefined}
119118
>
120119
{item.label}
121120
</span>

src/Selector/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export interface SelectorProps {
9999
domRef: React.Ref<HTMLDivElement>;
100100
}
101101

102-
const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> = (props, ref) => {
102+
const Selector: React.ForwardRefRenderFunction<RefSelectorProps, SelectorProps> = (props, ref) => {
103103
const inputRef = useRef<HTMLInputElement>(null);
104104
const compositionStatusRef = useRef<boolean>(false);
105105

@@ -274,6 +274,9 @@ const Selector: React.RefForwardingComponent<RefSelectorProps, SelectorProps> =
274274
};
275275

276276
const ForwardSelector = React.forwardRef<RefSelectorProps, SelectorProps>(Selector);
277-
ForwardSelector.displayName = 'Selector';
277+
278+
if (process.env.NODE_ENV !== 'production') {
279+
ForwardSelector.displayName = 'Selector';
280+
}
278281

279282
export default ForwardSelector;

0 commit comments

Comments
 (0)