- [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. - [CODE KNOWLEDGE] - use object desructuring for getting values from object.
EXAMPLE:
const { type, extraData, keysToRemove } = action;
- [NAMING] - use proper names for object copy and
BAD EXAMPLE:
const copy = { ...state }
GOOD EXAMPLE:
const stateCopy = { ...state }