Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

UseMemo cant read value from zod validation?

$
0
0

Need help,i used zod to validate my data and try to used function useMemo when i cursor to the value as in image the value can read from zod validation but when i put the value the error come out as image. I tried to put index to the value also doesn't work. What should i do?

const apiScheme = z.tuple([      z.object({         total_work_hours: z.number().nullable(),         normal_hours: z.number().nullable(),         overtime: z.number(),         public_holiday_hours: z.number(),         total_work_days: z.number(),         total_medical_leave: z.number(),         total_emergency_leave: z.number(),         total_public_holiday: z.number(),      }),      z.array(         z.object({            date: z.string(),            attendance: z.array(               z.object({                  outlet_name: z.string().nullable(),                  clock_in_type: z.string().nullable(),                  clock_in: z.number().nullable(),                  clock_out: z.number().nullable(),                  work_hour: z.number().nullable(),               }),            ),         }),      ),   ]);   // console.log(apiScheme);   const data1 = useMemo(() => {      if (responseAttendanceData) {         const parseData = apiScheme.parse(responseAttendanceData);         if (parseData) {        return parseData.map((value)=>{         return{            total_work_hours: value.total_work_hours,            normal_hours: z.number().nullable(),            overtime: z.number(),            public_holiday_hours: z.number(),            total_work_days: z.number(),            total_medical_leave: z.number(),            total_emergency_leave: z.number(),            total_public_holiday: z.number(),         }        })         }      }      return null;   }, [responseAttendanceData]);

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>