Tanikai/uniulm_mensa_frontend

Comparison of `undefined` against `null`

Closed this issue · 1 comments

So I noticed that you pass undefined to a MealElement here to indicate that there is no meal to display. But in MealElement.tsx:11 you are comparing this value against null not undefined.

IMHO there are two ways to go about this issue:

  1. Fix the comparison directly
  2. Move this logic out of the MealElement into CanteenMeals

I'd prefer option 2. as this is not really a concern of an individual meal, and a similar check already exists in CanteenMeals.

The mentioned line uses == instead of ===. This means that if the meal is undefined, it still returns the "canteen closed" component, as null == undefined returns true.

However, as you've said in your last sentence, it's not really the concern of the MealElement. I'll move it to CanteenMeals.