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 PropTypes from 'prop-types'; | |
import React, { Component } from 'react'; | |
import styles from './Styles.scss'; |
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 PropTypes from 'prop-types'; | |
import React from 'react'; | |
import styles from './Component.scss'; | |
const ComponentName = ({ prop, anotherProp, functionFromContainer, propsAreFromContainer, prop2 }) => { | |
const someConstant = constantVal; | |
const componentClickEvent = () => { | |
// do whatever, perhaps with someConstant; | |
}; |
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
https://medium.com/dailyjs/techniques-for-decomposing-react-components-e8a1081ef5da |
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
// ES5 | |
var multiply = function(a, b) { | |
return a * b; | |
}; | |
// ES6 | |
var multiply = (a, b) => { return a * b }; | |
// even neater | |
var multiply = (a, b) => a * b; |
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
getMain = (children) => { | |
return ( | |
<Switch> | |
<Route path={pathJoin(this.baseUrl, '/path/one')}> | |
<main className={styles.something}> | |
{children} | |
</main> | |
</Route> | |
<Route path={pathJoin(this.baseUrl, '/path/two')}> | |
<main className={styles.somethingElse}> |
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
function friend(friends){ | |
return friends.filter(n => n.length === 4) | |
} |
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
function descendingOrder(n){ | |
return parseInt(String(n).split('').sort().reverse().join('')) | |
} |
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
// A function is only pure if, given the same input, it will always produce the same output. | |
const highpass = (cutoff, value) => value >= cutoff; | |
highpass(5, 123); // true | |
highpass(5, 6); // true | |
highpass(5, 18); // true | |
highpass(5, 5); // true | |
highpass(5, 1); // false | |
highpass(5, 3); // false | |
highpass(5, 4); // false |
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
const keyArray = [ | |
['1'], | |
['A', 'B', 'C', '2'], | |
['D', 'E', 'F', '3'], | |
['G', 'H', 'I', '4'], | |
['J', 'K', 'L', '5'], | |
['M', 'N', 'O', '6'], | |
['P', 'Q', 'R', 'S', '7'], | |
['T', 'U', 'V', '8'], | |
['W', 'X', 'Y', 'Z', '9'], |
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
export const selectorName = state => { | |
return ... | |
} |
OlderNewer