frankcollins3 / Next-Water-App

Happy, Healthy Water Cycling App that tracks user/human fluid intake.
https://next-water-app.vercel.app
1 stars 0 forks source link

typescript interface not allowing for .find() methods [10:49am] #98

Closed frankcollins3 closed 1 year ago

frankcollins3 commented 1 year ago

attempting to do: modularize /dashboard.tsx -> and break different UI into different components to refactor.

error: Dashboard.tsx:70 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'find')

for this code: const getDay:any = hydroData.find(
(day) => moment(day.date, 'YYYY-M-D').format('MM-DD-YYYY') === formatHighlightDay ); if (getDay) {
console.log('getDay') console.log(getDay) // setSelectedDay(getDay); dispatch(SET_SELECTED_DAY(getDay)) dispatch(TOGGLE_PROGRESS_SHOW()) } }

for this interface: export interface HydroDataInterface { id:number, google_id:string, date:string, progress:number, weekday:string, status:string[], users_id:number }

proposed approach: 0: change redux state

1: generics with typescript.

// tbh about to deploy this app and redo: ghub.com/frankcollins3/mine-nugget-ts and add: graphql, @redux/toolkit, redis proper UI structure:

frankcollins3 commented 1 year ago

changing redux is working. postponing learning generics but will during next app.