My (@pongstr) opinion about shorthand coding techniques
Shorthand code is not really a replacement for normal coding but it is very handy and useful in some cases. There are tons of opinions and debates around this but, again it all comes down what is necessary for your codebase and using it responsibly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
class componentName extends Component { | |
constructor(props) { | |
super(props); | |
this.handleClicks = []; | |
this.props.friends.forEach(friend => { | |
this.handleClick[fiend.id] = this.handleClick.bind(this, friend.id); | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// O(1) | |
const todo = (state, action) => { | |
const actions = { | |
ADD_TODO: () => { | |
return { | |
id: action.id, | |
text: action.text, | |
completed: false | |
} | |
}, |