Skip to content

Commit

Permalink
fix: useGetDataindexColumns render bug
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Jan 11, 2022
1 parent 627a00f commit c5502b2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useDebounceFn from './utils/useDebounceFn';
import { depthFirstSearch } from './utils';
import useSafeState from './utils/useSafeState';
import useLocalColumns from './utils/useLocalColumns';
import useGetDataindexColumns, { GETKEY, ResizableUniqIdPrefix } from './utils/useGetDataindexColumns';
import useGetDataIndexColumns, { GETKEY, ResizableUniqIdPrefix } from './utils/useGetDataIndexColumns';
import useMemoizedFn from './utils/useMemoizedFn';

export type ColumnsState = {
Expand Down Expand Up @@ -205,4 +205,4 @@ function useTableResizableHeader<ColumnType extends ColumnOriginType<ColumnType>

export default useTableResizableHeader;

export { ResizableUniqIdPrefix, useGetDataindexColumns };
export { ResizableUniqIdPrefix, useGetDataIndexColumns };
4 changes: 2 additions & 2 deletions src/utils/useGetDataIndexColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ function getColumns<T extends ColumnOriginType<T>>(list: T[] | undefined) {
** 如果columns没有dataIndex,则按规则添加一个不重复的dataIndex
*/

function useGetDataindexColumns<T extends ColumnOriginType<T>>(columns: T[] | undefined) {
function useGetDataIndexColumns<T extends ColumnOriginType<T>>(columns: T[] | undefined) {
const dataIndexColumns = React.useMemo(() => getColumns(columns), [columns]) as T[] | undefined;

return dataIndexColumns || columns;
}

export default useGetDataindexColumns;
export default useGetDataIndexColumns;
4 changes: 2 additions & 2 deletions src/utils/useLocalColumns.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect, useMemo } from 'react';
import type { ColumnOriginType, ColumnsStateType } from '..';
import useGetDataindexColumns from './useGetDataindexColumns';
import useGetDataIndexColumns from './useGetDataIndexColumns';
import useMemoizedFn from './useMemoizedFn';

type LocalColumnsProp<T> = {
Expand All @@ -15,7 +15,7 @@ function useLocalColumns<T extends ColumnOriginType<T>>({
columns,
}: LocalColumnsProp<T>) {
// 列设置需要每一个column都有dataIndex或key
const columnsProp = useGetDataindexColumns(columns);
const columnsProp = useGetDataIndexColumns(columns);

// 初始化本地columns
const initLocalColumns = useMemoizedFn(() => {
Expand Down
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default defineConfig({
plugins: [
typescript({
tsconfig: path.resolve(__dirname, 'tsconfig.json'),
include: ['src/index.tsx', 'src/utils/useGetDataindexColumns.ts'],
include: ['src/index.tsx', 'src/utils/useGetDataIndexColumns.ts'],
}),
],
},
Expand Down

0 comments on commit c5502b2

Please sign in to comment.