Skip to content

Instantly share code, notes, and snippets.

function loggedIn() {
// ...
}
function requireAuth(nextState, replace) {
if (!loggedIn()) {
replace({
pathname: '/login'
})
}
BackAndroid.addEventListener("hardwareBackPress", () => {
if (navigator.getCurrentRoutes().length > 1) {
navigator.pop()
return true
} else {
return false
}
})
// actions/index.js imports all actions from its directory and exports them
import * as accountActions from "./accountActions"
import * as cartActions from "./cartActions"
export {
accountActions,
cartActions
}
// index.js imports the index.js files from each of these directories,
/*
lib/ (es5 code)
actions/
index.js
constants/
index.js
reducers/
index.js
utils/
function addProduct(product) {
return (dispatch, getState) => {
const someOtherValue = getState().foo.bar
dispatch({
type: ADD_PRODUCT,
data: product,
someOtherValue: someOtherValue
})
function addProduct(product) {
return {
type: ADD_PRODUCT,
data: product
}
}
{type: ADD_PRODUCT, data: product }
var npm = require("npm");
var fs = require("fs-extra");
var chokidar = require("chokidar");
var packagePaths = [
"../mobile-app/node_modules/shared-package/lib",
"../web-app/node_modules/shared-package/lib",
];
var noop = () => {};
/*
mobile-app/
node_modules/
shared-package/
lib/
native-app/
node_modules/
shared-package/
lib/
mobile-app/
node_modules/
shared-package/
lib/
native-app/
node_modules/
shared-package/
lib/
shared-package/
src/ (ES6 code we wrote)