Skip to content

Commit

Permalink
chore: add NODE_ENV to displayName (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
li-jia-nan committed Dec 26, 2023
1 parent 92a7445 commit c01fe37
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 14 deletions.
5 changes: 4 additions & 1 deletion src/OptionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,9 @@ const OptionList: React.ForwardRefRenderFunction<RefOptionListProps, {}> = (_, r
};

const RefOptionList = React.forwardRef(OptionList);
RefOptionList.displayName = 'OptionList';

if (process.env.NODE_ENV !== 'production') {
RefOptionList.displayName = 'OptionList';
}

export default RefOptionList;
7 changes: 5 additions & 2 deletions src/SelectTrigger.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export interface SelectTriggerProps {
onPopupMouseEnter: () => void;
}

const SelectTrigger: React.RefForwardingComponent<RefTriggerProps, SelectTriggerProps> = (
const SelectTrigger: React.ForwardRefRenderFunction<RefTriggerProps, SelectTriggerProps> = (
props,
ref,
) => {
Expand Down Expand Up @@ -180,6 +180,9 @@ const SelectTrigger: React.RefForwardingComponent<RefTriggerProps, SelectTrigger
};

const RefSelectTrigger = React.forwardRef<RefTriggerProps, SelectTriggerProps>(SelectTrigger);
RefSelectTrigger.displayName = 'SelectTrigger';

if (process.env.NODE_ENV !== 'production') {
RefSelectTrigger.displayName = 'SelectTrigger';
}

export default RefSelectTrigger;
7 changes: 5 additions & 2 deletions src/Selector/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface InputProps {
>;
}

const Input: React.RefForwardingComponent<InputRef, InputProps> = (
const Input: React.ForwardRefRenderFunction<InputRef, InputProps> = (
{
prefixCls,
id,
Expand Down Expand Up @@ -141,6 +141,9 @@ const Input: React.RefForwardingComponent<InputRef, InputProps> = (
};

const RefInput = React.forwardRef<InputRef, InputProps>(Input);
RefInput.displayName = 'Input';

if (process.env.NODE_ENV !== 'production') {
RefInput.displayName = 'Input';
}

export default RefInput;
13 changes: 6 additions & 7 deletions src/Selector/SingleSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
if (item) {
return null;
}
const hiddenStyle = hasTextInput ? { visibility: 'hidden' } as React.CSSProperties : undefined;
const hiddenStyle = hasTextInput
? ({ visibility: 'hidden' } as React.CSSProperties)
: undefined;
return (
<span
className={`${prefixCls}-selection-placeholder`}
style={hiddenStyle}
>
<span className={`${prefixCls}-selection-placeholder`} style={hiddenStyle}>
{placeholder}
</span>
);
Expand Down Expand Up @@ -108,14 +107,14 @@ const SingleSelector: React.FC<SelectorProps> = (props) => {
</span>

{/* Display value */}
{(!combobox && item) ? (
{!combobox && item ? (
<span
className={`${prefixCls}-selection-item`}
title={selectionTitle}
// 当 Select 已经选中选项时,还需 selection 隐藏但留在原地占位
// https://github.com/ant-design/ant-design/issues/27688
// https://github.com/ant-design/ant-design/issues/41530
style={hasTextInput ? { visibility: 'hidden' } as React.CSSProperties : undefined}
style={hasTextInput ? ({ visibility: 'hidden' } as React.CSSProperties) : undefined}
>
{item.label}
</span>
Expand Down
7 changes: 5 additions & 2 deletions src/Selector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export interface SelectorProps {
domRef: React.Ref<HTMLDivElement>;
}

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

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

const ForwardSelector = React.forwardRef<RefSelectorProps, SelectorProps>(Selector);
ForwardSelector.displayName = 'Selector';

if (process.env.NODE_ENV !== 'production') {
ForwardSelector.displayName = 'Selector';
}

export default ForwardSelector;

1 comment on commit c01fe37

@vercel
Copy link

@vercel vercel bot commented on c01fe37 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

select – ./

select-git-master-react-component.vercel.app
select-react-component.vercel.app
select.vercel.app

Please sign in to comment.