const items = useMemo(() => { var MainLevel = MainData.reduce((resData: any, item: any) => { resData = { ...resData, [item]: [] } return resData }, {}) return Object.entries(DetailData.reduce((resData1: any, item1: any) => { resData1[item1.MainData] = [...resData1[item1.MainData], item1] console.log(resData1,"resData11") return resData1 }, MainLevel)) }, [])