-
[CODE STYLE] - don't mutate object or arrays - it will cause unexpected results later on. You should make copy using
Object.assign
orspread
operator -
[CODE STYLE]: Use switch statement if you have limited amount of conditions.
-
[CODE STYLE]: switch/case should always have default case for error handling.
-
[DONT REPEAT YOURSELF] - If you perform same action in all
switch
cases - do it just once afterwards. -
[NAMING] - use proper names for object copy
BAD EXAMPLE:
const copy = { ...state }
GOOD EXAMPLE:
const stateCopy = { ...state }