From b92cd9a18d33d19470f4488719d242e71785c27e Mon Sep 17 00:00:00 2001 From: DinhTran Date: Mon, 26 Feb 2024 16:31:27 +0700 Subject: [PATCH] fix: display keys as number --- src/commons/hooks/useDisableJsonKey.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commons/hooks/useDisableJsonKey.tsx b/src/commons/hooks/useDisableJsonKey.tsx index 6dd8884e28..cb975c6623 100644 --- a/src/commons/hooks/useDisableJsonKey.tsx +++ b/src/commons/hooks/useDisableJsonKey.tsx @@ -23,7 +23,8 @@ const useDisableJsonKey = (data: unknown): { trigger: () => void; keyRenderer: J return ; }; keyRenderer.when = ({ path }) => { - const num = Number(path[path.length - 1]); + const newNum = path.filter((i) => typeof i === "number"); + const num = Number(newNum[newNum.length - 1]); return !isNaN(num) && num < MAX_INDEX; }; return { keyRenderer, trigger };