Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Make opts optional

dominik-zeglend56654896619
diff --git a/saleor/static/dashboard-next/hooks/useStateFromProps.ts b/saleor/static/dashboard-next/hooks/useStateFromProps.ts
index 6b4fcd1f40..6089f3ecb4 100644
--- a/saleor/static/dashboard-next/hooks/useStateFromProps.ts
+++ b/saleor/static/dashboard-next/hooks/useStateFromProps.ts
@@ -8,14 +8,16 @@ export interface UseStateFromPropsOpts<T> {
function useStateFromProps<T>(
data: T,
- opts: UseStateFromPropsOpts<T>
+ opts?: UseStateFromPropsOpts<T>
): [T, Dispatch<SetStateAction<T>>] {
const [state, setState] = useState(data);
const [prevData, setPrevData] = useState(data);
-
- const { mergeFunc, onRefresh } = opts;
+ if (!opts) {
+ opts = {};
+ }
if (!isEqual(prevData, data)) {
+ const { mergeFunc, onRefresh } = opts;
const newData =
typeof mergeFunc === "function" ? mergeFunc(prevData, state, data) : data;
setState(newData);