Skip to content

Commit

Permalink
Fix conditional rendering hook issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mguellsegarra committed Sep 10, 2023
1 parent bf9bede commit 4b2686a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/react-formiga-table",
"version": "0.8.5",
"version": "0.8.6",
"scripts": {
"build": "tsc && vite build",
"prepublishOnly": "npm run build",
Expand Down
23 changes: 15 additions & 8 deletions src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,19 @@ export const Table = (props: TableProps) => {
selectionRowKeys: selectionRowKeysProps,
} = props;

if (loading) {
return loadingComponent;
}

const {
selectedRowKeys,
toggleAllRowsSelected,
isRowSelected,
changeSelected,
} = useSelectable({
selectionRowKeysProps
selectionRowKeysProps,
});

const onChange = useShiftSelected(dataSource.map(el => el.id), changeSelected);

const onChange = useShiftSelected(
dataSource.map((el) => el.id),
changeSelected
);
const { localSorter, getColumnSorter, handleColumnClick } =
useSortable(sorter);

Expand Down Expand Up @@ -80,8 +79,16 @@ export const Table = (props: TableProps) => {
toggleAllRowsSelected(getAllVisibleKeys());
}, [toggleAllRowsSelected, getAllVisibleKeys]);

if (loading) {
return loadingComponent;
}

return (
<Container height={height} canClick={onRowDoubleClick !== undefined} readonly={readonly}>
<Container
height={height}
canClick={onRowDoubleClick !== undefined}
readonly={readonly}
>
<table>
<thead>
<tr>
Expand Down

0 comments on commit 4b2686a

Please sign in to comment.