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

React - Uncaught TypeError: Cannot read properties of undefined (reading 'CREATE_PROGRAM')

$
0
0

I'd like to use an enum instead of magic string.

But for some reason React doesn't allow me that:

Uncaught TypeError: Cannot read properties of undefined (reading 'CREATE_PROGRAM')

Yet the code seems fairly simple:

src/router/Router.tsx

export enum Routes {  HOME = 'Home',  CREATE_PROGRAM = 'CreateProgram',  ADD_EXERCISES = 'AddExercises',  EDIT_WORKOUT = 'EditWorkout',  EXERCISE_SETTINGS = 'ExerciseSettings',  WORKOUT_PREVIEW = 'WorkoutPreview',  SETS_RUNNER = 'SetsRunner',  WORKOUT_SESSION_SUMMARY = 'WorkoutSessionSummary',}

src/home/repositories/home.fake-data.repository.ts

import { Routes } from '../../router/Router'export const dailyTasksFakeData: { description: string; route: Routes }[] = [  {    description: 'Create your first program',    route: Routes.CREATE_PROGRAM,  },]

Viewing all articles
Browse latest Browse all 6287

Trending Articles