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 Utils from 'utils.js'; | |
// Load the config. | |
let config = Utils.initConfig(); | |
// Later, use it | |
if ( ! Utils.configSettingExists( config, 'foo' ) ) { | |
Utils.printConfigFormatInstructions(); | |
} |
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
// Old | |
export default { | |
// ... | |
} | |
// New | |
export default class { | |
// ... | |
} |
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 default class AsyncStorageSupplement { | |
static multiGet(keys) { | |
return Promise.all( | |
keys.map(key => AsyncStorage.getItem(key)) | |
) | |
} | |
static multiRemove(keys) { | |
return Promise.all( | |
keys.map(key => AsyncStorage.removeItem(key)) |
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
var MyApp = {}; | |
MyApp.namespace = function() { | |
var ln = arguments.length, i, value, split, x, xln, parts, object; | |
for (i = 0; i < ln; i++) { | |
value = arguments[i]; | |
parts = value.split("."); | |
object = window[parts[0]] = Object(window[parts[0]]); | |
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
// Less Coupled | |
var CountrySelectClass = function() { | |
var countriesIveBeenTo = { | |
'BE': 'Belgium', | |
'CR': 'Costa Rica', | |
'IT': 'Italy', | |
'US': 'United States of America', | |
'UK': 'United Kingdom' | |
}; |
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 Colors from './colors'; | |
export default const Typography = { | |
heading1: { | |
fontSize: 30, | |
fontWeight: 'bold', | |
lineHeight: 32, | |
color: Colors.black | |
}, |
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'; | |
import { Text, View } from 'react-native'; | |
import Styles from './Card.style'; | |
class Card extends Component { | |
render() { | |
return ( | |
<View style={ Styles.container }> | |
<View style={ Styles.titleContainer }> |
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
let Style = StyleSheet.create({ | |
container: { borderRadius: 5 }, | |
heading: { backgroundColor: 'beige', padding: 5 }, | |
headingText: { color: 'black', fontSize: 16, fontWeight: 'bold' }, | |
body: { padding: 5 }, | |
bodyText: { color: 'black', fontSize: 12 } | |
}) | |
class SimpleComponentWithoutLiterals extends Component { | |
render() { |
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
class SimpleComponent extends Component { | |
render() { | |
return ( | |
<View style={{ borderRadius: 5 }}> | |
<View style={{ backgroundColor: 'beige', padding: 5 }}> | |
<Text style={{ color: 'black', fontSize: 16, fontWeight: 'bold' }}>{ this.props.title }</Text> | |
</View> | |
<View style={{ padding: 5 }}> | |
<Text style={{ color: 'black', fontSize: 12 }}>{ this.props.bodyText }</Text> | |
</View> |
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
class SimpleComponentWithCascade extends Component { | |
render() { | |
return ( | |
<View style={[ ComponentStyles.container, LayoutStyles.marginBottom ]}> | |
<View style={[ ComponentStyles.heading, LayoutStyles.paddingSm ]}> | |
<Text style={[ ComponentStyles.headingText, TypographyStyles.heading3, TextColors.black ]}>{ this.props.title }</Text> | |
</View> | |
<View style={[ ComponentStyles.body, LayoutStyles.paddingSm ]}> | |
<Text style={[ ComponentStyles.bodyText, TypographyStyles.bodyText, TextColors.darkGrey ]}>{ this.props.bodyText }</Text> | |
</View> |