Visit my blog or connect with me on Twitter
git init
or
function getDrink (type) { | |
var drinks = { | |
'coke': 'Coke', | |
'pepsi': 'Pepsi', | |
'lemonade': 'Lemonade', | |
'default': 'Default item' | |
}; | |
return 'The drink I chose was ' + (drinks[type] || drinks['default']); | |
} |
//by default | |
//react-native run-ios | |
//iPhone 4 | |
react-native run-ios --simulator "iPhone ${1:-4}" | |
//iPhone 4s | |
react-native run-ios --simulator "iPhone ${1:-4s}" | |
//iPhone 5 |
import React from 'react'; | |
const checkSize = size => { | |
switch (size) { | |
case 'large': | |
return 100; | |
case 'medium': | |
return 75; | |
default: | |
return 50; |
import React from 'react'; | |
import { ListView } from 'react-native'; | |
export default class extends React.PureComponent { | |
constructor(props) { | |
super(props); | |
const { data, dataSource, rowHasChanged: _rowHasChanged } = props; | |
this.state.data = data || []; |
Visit my blog or connect with me on Twitter
git init
or
if (!process.env.FROM_EMAIL) { | |
console.log('Please set: FROM_EMAIL environment variable. This is a validated email address to send emails from to other users for email verification, reset pwd etc') | |
process.exit(); | |
} | |
if(!process.env.POSTMARK_API_TOKEN) { | |
console.error('Error! Please set POSTMARK_API_TOKEN from postmark email service.'); | |
process.exit(); | |
} |
export const slugifyText = text => | |
text | |
.toString() | |
.toLowerCase() | |
.replace(/\s+/g, '-') // Replace spaces with - | |
.replace(/[^\w-]+/g, '') // Remove all non-word chars | |
.replace(/\-\-+/g, '-') // Replace multiple - with single - | |
.replace(/^-+/, '') // Trim - from start of text | |
.replace(/-+$/, ''); |
// 1. Define a state variable for showing/hiding the action-button | |
state = { | |
isActionButtonVisible: true | |
} | |
// 2. Define a variable that will keep track of the current scroll position | |
_listViewOffset = 0 | |
// 3. Add an onScroll listener to your listview/scrollview | |
<ListView |
const routes = ( | |
<Router history={browserHistory}> | |
<Route path="/"> | |
<Route path="/posts/:id" component={PostPage} /> | |
</Route> | |
</Router> | |
) | |
<button onClick={() => browserHistory.push(`/posts/${post.id}`)}></button> |
{ | |
"name": "component-archetype", | |
"version": "0.0.1-semantic", | |
"description": "A new Webpack boilerplate with hot reloading React components, and error handling on module and component level.", | |
"main": "lib/index.js", | |
"scripts": { | |
"clean": "rimraf lib", | |
"build:webpack": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js", | |
"build:babel": "NODE_ENV=lib babel src --out-dir lib", | |
"build": "npm run clean && npm run build:babel", |