iamshaunjp / iamshaunjp/MERN-Stack-Tutorial
workoutsContext.js | TypeError: e is null | spread operator (...state)
Open
- Dominant language
- No language data
- Stars
- 401
- Forks
- 252
- PR merge metrics
- No merged PRs in 30d
Description
case 'CREATE_WORKOUTS' that returns workouts: [action.payload, ...state.workouts], raises " TypeError: e is null " when state.workouts is empty due to spread operator !
please add a if condition to avoid it , like below
case 'CREATE_WORKOUTS':
if (!state.workouts)
return {
workouts: [action.payload]
}
else
return {
workouts: [action.payload, ...state.workouts]
}
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.