react-live-data-table 1.0.11 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-live-data-table",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Your React component package with Tailwind",
5
5
  "main": "src/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -16,7 +16,7 @@ function ReactDataTable({
16
16
  emptyText,
17
17
  rowHeights = 40,
18
18
  headerProps = {},
19
- selected = {},
19
+ selected={},
20
20
  showSelectAllCheckbox=true
21
21
  }) {
22
22
  const tableContainerRef = React.useRef(null);
@@ -24,11 +24,16 @@ function ReactDataTable({
24
24
  const [isFetching, setIsFetching] = React.useState(false);
25
25
  const [pageParam, setPageParam] = React.useState(1);
26
26
  const [selectedRows, setSelectedRows] = React.useState(selected);
27
+ const previousSelected = React.useRef(selected);
27
28
 
28
-
29
+
29
30
  useEffect(() => {
30
- setSelectedRows({ ...selected })
31
- }, [selected])
31
+ if (JSON.stringify(previousSelected.current) !== JSON.stringify(selected)) {
32
+ setSelectedRows({...selected});
33
+ previousSelected.current = selected;
34
+ }
35
+ }, [selected]);
36
+
32
37
 
33
38
  useEffect(() => {
34
39
  setData({ pages: [], meta: { totalPages: 1 } });
@@ -171,17 +176,15 @@ function ReactDataTable({
171
176
  minWidth: 50,
172
177
  textAlign: "center",
173
178
  header: ({ data }) => (
174
- showSelectAllCheckbox ? <div className="flex items-center justify-center h-[40px]">
175
- <input
179
+ <div className="flex items-center justify-center h-[40px]">
180
+ {showSelectAllCheckbox && <input
176
181
  id={data.id}
177
182
  type="checkbox"
178
183
  className='bg-gray-700 rounded-4 border-gray-200 text-blue-400 focus:ring-0 focus:ring-white'
179
184
  checked={Object.keys(selectedRows).length > 0 && data.every(row => selectedRows[row.id])}
180
185
  onChange={(e) => handleSelectAll(e.target.checked, flatData)}
181
- />
186
+ />}
182
187
  </div>
183
- :
184
- <div className="flex items-center justify-center h-[40px]"></div>
185
188
  ),
186
189
  cell: ({ row }) => {
187
190
  return (