A collection of my docs, dot files, and anything else related to coding.
Slack docs Heroku docs Setup docs
- Modifier classes should be kept as small as possible
- Comment dividers, /** sdfdsf **/
frontend standards (eslint here)
- No duplicate or generated values in your state.
- Your state should represent the absolute minimum amount of data
react app guide Testing
Switch Cases in js were poorly designed. They not faster than other methods, also each case must have a break;
at then end of it or it will cascade into the next case. This can produce unseens bugs that are very hard to reproduce and track down.
The better approach is to produce an object mapping of your 'cases' and 'results'. This has the added benefit of easily being passed around, dynamically generated, or externalized into a config file if it becomes very large. Lodash's _.result
is excellent for this, providing pure valueand functional cases, as well as defaults.
const getColor = (name, default='#333')=>{
const mapping = {
red : '#c0392b',
blue : '#2980b9',
green : '#27ae60',
rand : ()=>_.sample(_.values(mapping))
};
return _.result(mapping, name.toLower(), default)
};
getColor('Green'); //'#27ae60'
getColor('Maroon'); //'#333'
Use Arrow Functions