iamshaunjp / iamshaunjp/MERN-Stack-Tutorial
workoutsContext.js | TypeError: e is null | spread operator (...state)
- 主要言語
- 言語のデータがありません
- スター
- 401
- フォーク
- 252
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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]
}
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Open workoutsContext.js and locate the CREATE_WORKOUTS reducer case that spreads state.workouts. Check how it behaves when workouts is null or empty, then ensure the case returns the new workout without a TypeError and verify the reducer still preserves existing workouts.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- frontend
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100