diff --git a/package.json b/package.json index ee6851a06..f779cbb0e 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "lodash": "^4.17.14", "lodash-es": "^4.17.14", "moment-timezone": "^0.5.26", - "qs": "^6.7.0", + "qs": "^6.9.0", "react": "^16.9.0", "react-apollo": "^3.0.0", "react-dom": "^16.9.0", diff --git a/src/hooks/useListActions.ts b/src/hooks/useListActions.ts index 43f38b88c..81fd789b1 100644 --- a/src/hooks/useListActions.ts +++ b/src/hooks/useListActions.ts @@ -1,12 +1,10 @@ -import { useEffect, useState } from "react"; +import useStateFromProps from "./useStateFromProps"; function useListActions( initial: TData[] = [], compareFunc: (a: TData, b: TData) => boolean = (a, b) => a === b ) { - const [listElements, setListElements] = useState(initial); - - useEffect(() => setListElements(initial), [JSON.stringify(initial)]); + const [listElements, setListElements] = useStateFromProps(initial); function isSelected(data: TData) { return !!listElements.find(listElement => compareFunc(listElement, data)); diff --git a/src/products/index.tsx b/src/products/index.tsx index 5116bb43f..e08553b87 100644 --- a/src/products/index.tsx +++ b/src/products/index.tsx @@ -35,6 +35,7 @@ const ProductList: React.FC> = ({ location }) => { ? findInEnum(qs.sort, ProductListUrlSortField) : ProductListUrlSortField.name }; + return ; }; diff --git a/src/products/urls.ts b/src/products/urls.ts index 2f240496f..a24f7e570 100644 --- a/src/products/urls.ts +++ b/src/products/urls.ts @@ -1,6 +1,7 @@ -import { stringify as stringifyQs } from "qs"; import urlJoin from "url-join"; +import { stringifyQs } from "../utils/urls"; + import { ActiveTab, BulkAction, diff --git a/src/utils/urls.ts b/src/utils/urls.ts new file mode 100644 index 000000000..332488a80 --- /dev/null +++ b/src/utils/urls.ts @@ -0,0 +1,7 @@ +import { stringify } from "qs"; + +export function stringifyQs(params: object): string { + return stringify(params, { + indices: false + }); +}