From 13b79eb2cf649142311c5137c4fc730fbb4b9477 Mon Sep 17 00:00:00 2001 From: Satyajit Sahoo Date: Thu, 11 Jan 2024 11:30:26 +0100 Subject: [PATCH] refactor: use Object.entries instead of reduce --- example/src/index.tsx | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/example/src/index.tsx b/example/src/index.tsx index b743f15f87..7e4a56858d 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -77,30 +77,22 @@ const linking: LinkingOptions = { }, }, NotFound: '*', - ...SCREEN_NAMES.reduce( - (acc, name) => { + ...Object.fromEntries( + Object.entries(SCREENS).map(([name, { linking }]) => { // Convert screen names such as SimpleStack to kebab case (simple-stack) const path = name .replace(/([A-Z]+)/g, '-$1') .replace(/^-/, '') .toLowerCase(); - const config = { - path, - screens: SCREENS[name].linking, - }; - - // @ts-expect-error: acc is not readonly - acc[name] = config; - - return acc; - }, - {} as { - [Key in keyof typeof SCREENS]: { - path: string; - screens: (typeof SCREENS)[Key]['linking']; - }; - } + return [ + name, + { + path, + screens: linking, + }, + ]; + }) ), }, },