@bento-core/table 1.0.0-c3dc.29 → 1.0.0-c3dc.30
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.
|
@@ -46,12 +46,12 @@ const CPIModal = _ref => {
|
|
|
46
46
|
} = _ref;
|
|
47
47
|
const [sortBy, setSortBy] = (0, _react.useState)('associated_id');
|
|
48
48
|
const [sortOrder, setSortOrder] = (0, _react.useState)('asc');
|
|
49
|
-
const [data, setData] = (0, _react.useState)(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
49
|
+
const [data, setData] = (0, _react.useState)(row.cpi_data);
|
|
50
|
+
(0, _react.useEffect)(() => {
|
|
51
|
+
setData(row.cpi_data);
|
|
52
|
+
}, [row]);
|
|
53
53
|
const sortingData = (column, newOrder) => {
|
|
54
|
-
const sortedData = data.sort((a, b) => a[column].localeCompare(b[column]));
|
|
54
|
+
const sortedData = [...data].sort((a, b) => a[column].localeCompare(b[column]));
|
|
55
55
|
if (newOrder === 'desc') {
|
|
56
56
|
return sortedData.reverse();
|
|
57
57
|
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
Modal,
|
|
@@ -44,13 +44,15 @@ const CPIModal = ({
|
|
|
44
44
|
}) => {
|
|
45
45
|
const [sortBy, setSortBy] = useState('associated_id');
|
|
46
46
|
const [sortOrder, setSortOrder] = useState('asc');
|
|
47
|
-
const [data, setData] = useState(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const [data, setData] = useState(row.cpi_data);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
setData(row.cpi_data);
|
|
51
|
+
}, [row]);
|
|
52
|
+
|
|
51
53
|
|
|
52
54
|
const sortingData = (column, newOrder) => {
|
|
53
|
-
const sortedData = data.sort((a, b) => a[column].localeCompare(b[column]));
|
|
55
|
+
const sortedData = [...data].sort((a, b) => a[column].localeCompare(b[column]));
|
|
54
56
|
|
|
55
57
|
if (newOrder === 'desc') {
|
|
56
58
|
return sortedData.reverse();
|