CEC-5135: remove prop from useEffect deps (#459)

* resolve localStorage race condition

* fix

* fix

* CEC-5135: remove prop from deps

* update test
This commit is contained in:
Tristan Timblin
2023-10-03 17:10:54 -07:00
committed by GitHub
parent e5ccb23443
commit eae44c9249
4 changed files with 32 additions and 36 deletions

View File

@@ -67,7 +67,6 @@ const CarSelectionTable = (props) => {
const [order, setOrder] = useState("asc");
const { getVehicles, vehicles, totalVehicles } = useVehicleContext();
const { setMessage } = useStatusContext();
const { search: searchTerm } = search;
const handleSort = (_event, property) => {
if (property === orderBy) {
@@ -111,21 +110,22 @@ const CarSelectionTable = (props) => {
};
useEffect(() => {
const options = {
const queryParams = {
...search,
limit: pageSize,
offset: pageSize * pageIndex,
order: `${orderBy} ${order}`,
};
(async () => {
try {
await getVehicles(Object.assign(options, search), token);
await getVehicles(queryParams, token);
} catch (e) {
setMessage(e.message);
logger.warn(e.stack);
}
})();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [pageIndex, pageSize, orderBy, order, search, token]);
}, [pageIndex, pageSize, orderBy, order, token]);
useEffect(() => {
setPageIndex(0);
@@ -172,7 +172,7 @@ const CarSelectionTable = (props) => {
<br />
<ECUList
list={row.ecu_list}
search={searchTerm}
search={search.search}
searchedOnly={true}
/>
</>