Based on dribbble shot https://dribbble.com/shots/2097042-Widget-Weather by kylor
A Pen by Josh Bader on CodePen.
function fetchAllProjects() { | |
return dispatch => { | |
console.log('1') | |
dispatch(xxx()) | |
dispatch({ type: 'REQUEST_ALL_PROJECTS' }); | |
console.log('2') | |
ProjectsApi.getAllProjects() | |
.then(projects => { | |
dispatch({ type: 'SUCCESS_ALL_PROJECTS', projects: fromJS(projects) }); | |
}) |
import mongoose from 'mongoose'; | |
let schema = new mongoose.Schema({ | |
email: { type: String, required: true, unique: true }, | |
password: { type: String, required: true } | |
}); | |
schema.statics.findOrCreate = async (conditions, opt_attr) => { | |
let document = await User.findOne(conditions); |
import React, { PropTypes, Component } from 'react' | |
import { getRef, listToArray } from '../utils/firebase' | |
import { ErrorMessage, Loading } from '../Theme' | |
/* | |
```js | |
<Ref path="/somewhere"> | |
{({ error, loaded, value }) => ( | |
// `value` is an object w/ keys |
const addAccountToTransactions = (txs, accounts) => ( | |
txs.map(tx => ( | |
// add the relationship | |
{ | |
...tx, | |
account: accounts[tx.accountKey] | |
} | |
)) | |
) |
// routes.js | |
const routes = [ | |
{ | |
path: '/', | |
component: Home, | |
exact: true | |
}, | |
{ | |
path: '/gists', | |
component: Gists |
Based on dribbble shot https://dribbble.com/shots/2097042-Widget-Weather by kylor
A Pen by Josh Bader on CodePen.
Yes...it's true...redux is smart....smarter than you even know. It really does want to help you. It strives to be sane and easy to reason about. With that being said, redux gives you optimizations for free that you probably were completely unaware of.
connect
is the most important thing in redux land IMO. This is where you tie the not between redux and your underlying
components. You usually take state and propogate it down your component hiearchy in the form of props. From there, presentational
export default [ | |
'Afghanistan', | |
'Albania', | |
'Algeria', | |
'Andorra', | |
'Angola', | |
'Antigua & Deps', | |
'Argentina', | |
'Armenia', | |
'Australia', |
export default [ | |
"AFGHANISTAN", | |
"ALBANIA", | |
"ALGERIA", | |
"AMERICAN SAMOA", | |
"ANDORRA", | |
"ANGOLA", | |
"ANGUILLA", | |
"ANTARCTICA", | |
"ANTIGUA AND BARBUDA", |
// Usually I use this in my app's config file, in case I need to disable all cache from the app | |
// Cache is from `js-cache`, something like `import Cache from 'js-cache';` | |
const cacheable = true, | |
cache = new Cache(); | |
// On request, return the cached version, if any | |
axios.interceptors.request.use(request => { | |
// Only cache GET requests | |
if (request.method === 'get' && cacheable) { |