From 28089626bc58d33749f9706b03f6d61af9337c55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A0=97=E5=98=89=E7=94=B7?= <574980606@qq.com> Date: Thu, 18 Jan 2024 09:21:58 +0800 Subject: [PATCH] chore: add process.env.NODE_ENV --- src/Body/BodyRow.tsx | 4 +++- src/Body/index.tsx | 4 +++- src/FixedHolder/index.tsx | 4 +++- src/Header/HeaderRow.tsx | 6 ++++-- src/Table.tsx | 6 ++---- src/VirtualTable/index.tsx | 6 ++---- src/hooks/useRenderTimes.tsx | 5 ++++- tests/Virtual.spec.tsx | 2 +- 8 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Body/BodyRow.tsx b/src/Body/BodyRow.tsx index 928d3b808..1b6be8393 100644 --- a/src/Body/BodyRow.tsx +++ b/src/Body/BodyRow.tsx @@ -208,6 +208,8 @@ function BodyRow( ); } -BodyRow.displayName = 'BodyRow'; +if (process.env.NODE_ENV !== 'production') { + BodyRow.displayName = 'BodyRow'; +} export default responseImmutable(BodyRow); diff --git a/src/Body/index.tsx b/src/Body/index.tsx index 1a3c77a13..3173fa22d 100644 --- a/src/Body/index.tsx +++ b/src/Body/index.tsx @@ -114,6 +114,8 @@ function Body(props: BodyProps) { ); } -Body.displayName = 'Body'; +if (process.env.NODE_ENV !== 'production') { + Body.displayName = 'Body'; +} export default responseImmutable(Body); diff --git a/src/FixedHolder/index.tsx b/src/FixedHolder/index.tsx index b7e48ce7f..25fc5d1dd 100644 --- a/src/FixedHolder/index.tsx +++ b/src/FixedHolder/index.tsx @@ -170,7 +170,9 @@ const FixedHolder = React.forwardRef>( ); }); -FixedHolder.displayName = 'FixedHolder'; +if (process.env.NODE_ENV !== 'production') { + FixedHolder.displayName = 'FixedHolder'; +} /** Return a table in div as fixed element which contains sticky info */ // export default responseImmutable(FixedHolder); diff --git a/src/Header/HeaderRow.tsx b/src/Header/HeaderRow.tsx index 87ff81042..864dc0bc5 100644 --- a/src/Header/HeaderRow.tsx +++ b/src/Header/HeaderRow.tsx @@ -54,7 +54,7 @@ function HeaderRow({ flattenColumns, stickyOffsets, direction, - column + column, ); let additionalProps: React.HTMLAttributes; @@ -81,6 +81,8 @@ function HeaderRow({ ); } -HeaderRow.displayName = 'HeaderRow'; +if (process.env.NODE_ENV !== 'production') { + HeaderRow.displayName = 'HeaderRow'; +} export default HeaderRow; diff --git a/src/Table.tsx b/src/Table.tsx index 7b7751554..76b36818d 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -877,10 +877,8 @@ function Table( } export type ForwardGenericTable = (( - props: TableProps & { ref?: React.Ref }, -) => React.ReactElement) & { - displayName?: string; -}; + props: TableProps & React.RefAttributes, +) => React.ReactElement) & { displayName?: string }; const RefTable = React.forwardRef(Table) as ForwardGenericTable; diff --git a/src/VirtualTable/index.tsx b/src/VirtualTable/index.tsx index eb59f7ff1..99620f60c 100644 --- a/src/VirtualTable/index.tsx +++ b/src/VirtualTable/index.tsx @@ -84,10 +84,8 @@ function VirtualTable(props: VirtualTableProps, ref: Rea } export type ForwardGenericVirtualTable = (( - props: TableProps & { ref?: React.Ref }, -) => React.ReactElement) & { - displayName?: string; -}; + props: TableProps & React.RefAttributes, +) => React.ReactElement) & { displayName?: string }; const RefVirtualTable = React.forwardRef(VirtualTable) as ForwardGenericVirtualTable; diff --git a/src/hooks/useRenderTimes.tsx b/src/hooks/useRenderTimes.tsx index 79b85a6c8..a37fc6681 100644 --- a/src/hooks/useRenderTimes.tsx +++ b/src/hooks/useRenderTimes.tsx @@ -38,4 +38,7 @@ export const RenderBlock = React.memo(() => { const times = useRenderTimes(); return

Render Times: {times}

; }); -RenderBlock.displayName = 'RenderBlock'; + +if (process.env.NODE_ENV !== 'production') { + RenderBlock.displayName = 'RenderBlock'; +} diff --git a/tests/Virtual.spec.tsx b/tests/Virtual.spec.tsx index 10742ffb5..44c2f18af 100644 --- a/tests/Virtual.spec.tsx +++ b/tests/Virtual.spec.tsx @@ -77,7 +77,7 @@ describe('Table.Virtual', () => { }); } - function getTable(props?: Partial> & { ref?: React.Ref }) { + function getTable(props?: Partial> & React.RefAttributes) { return render(