[based on a true story]
So. Your friend's about to teach you how to make a website. Great!
You make a file, and you save it as 'index.html'. Why it's called 'index' isn't really explained to you, but whatever.
You type the following.
hello world[based on a true story]
So. Your friend's about to teach you how to make a website. Great!
You make a file, and you save it as 'index.html'. Why it's called 'index' isn't really explained to you, but whatever.
You type the following.
hello world| <!-- | |
| What? | |
| HTML Starter Template for rock-solid Web Apps | |
| Where? | |
| Get the latest template here: https://gist.github.com/matthewmueller/cb33e2c5f6834511cd45f17b59271052 |
| /** Use the built-in document viewer in devtools to inspect your VDOM. | |
| * Usage in console: | |
| * viewComponentTree(document.body) | |
| */ | |
| function viewComponentTree(node) { | |
| let doc = new DOMParser().parseFromString('', 'application/xml'); | |
| function visitor(dom) { | |
| let el, c; | |
| if (dom instanceof Node) { | |
| el = dom.cloneNode(); |
| // HoC | |
| // localize({ a:'b' })(MyFoo) | |
| const localize = dict => Child => class Connected extends Component { | |
| getChildContext() { | |
| return { dict } | |
| } | |
| render(props) { | |
| return <Child {...props} /> | |
| } | |
| } |
| // getComponent is a function that returns a promise for a component | |
| // It will not be called until the first mount | |
| function asyncComponent(getComponent) { | |
| return class AsyncComponent extends React.Component { | |
| static Component = null; | |
| state = { Component: AsyncComponent.Component }; | |
| componentWillMount() { | |
| if (!this.state.Component) { | |
| getComponent().then(Component => { |
pure() can be used as a higher order function or a decorator.
When passed a pure functional component, it wraps the function in a classful Component with a shouldComponentUpdate() that ignores renders for unchanged props.
When passed a classful Component, it injects a shouldComponentUpdate() method into the Component's prototype that ignores renders for unchanged props & state.
import pure from 'pure-component';Wrap fetch() in a memoize.
Not only does this cache repeated requests for the same resource, it also de-dupes concurrent requests!
Notes:
| import { Component } from 'react' | |
| import { createStore, combineReducers } from 'redux' | |
| import parseLinkHeader from 'parse-link-header' | |
| const START = 'start' | |
| const SUCCEED = 'succeed' | |
| const ERROR = 'error' | |
| const inflight = (state={}, action) => ( | |
| ((state) => ( |