Comparison of `undefined` against `null`
Closed this issue · 1 comments
LukasPietzschmann commented
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:
- Fix the comparison directly
- Move this logic out of the
MealElement
intoCanteenMeals
I'd prefer option 2. as this is not really a concern of an individual meal, and a similar check already exists in CanteenMeals
.
Tanikai commented
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
.