Skip to content

Instantly share code, notes, and snippets.

var FlickrImageTime = React.createClass({
render: function() {
return (
<h3>Last updated: {moment(this.props.lastUpdate * 1000).fromNow()}</h3>
)
}
})
var FlickrImage = React.createClass({
render: function() {
@vojtatranta
vojtatranta / stav.js
Created October 1, 2016 23:01
Bezstavová změna stavu
// většina tříd má vnitřní stav
class Store {
constructor(someState) {
this._state = someState
}
setState(state) {
this._state = state
}
var currentReducer = reducer
var currentState = preloadedState
var currentListeners = []
var nextListeners = currentListeners
var isDispatching = false
function dispatch(action) {
if (!isPlainObject(action)) {
throw new Error(
const createDispatch = (state, doThingsWithUpdatedState) => {
return (executeChange) => {
const newState = executeChange(state)
return doThingsWithUpdatedState(newState, createDispatch(newState, doThingsWithUpdatedState))
}
}
const initialState = { counter: 0 }
const dispatch = createDispatch(initialState, (newState, dispatch) => {
// runtime, co se dá ukrýt
const composeAsync = (...fns) => {
const shiftedFns = fns.slice()
return (...args) => new Promise(resolve => resolve(...args))
.then(compose.apply(this, shiftedFns.map(fn => promiseOrValue => {
if (promiseOrValue instanceof Promise) {
return promiseOrValue.then(fn)
}
<PhotoPicker
pickPhoto: this.props.pickingProfilePhoto,
onPhotoPicked: this._handlePhotoShot,
onPhotoPickCanceld: this._handlephotoCancel,
/>
class ClassLikeCurry {
constructor() {
this.state = {}
}
getState() {
return this.state
}
setState(state) {
require.ensure([], (require) => {
const page = React.createFactory(require('./druha-stranka'))
this.setState({ page, url })
})
<body><div id="app"></div></body>
<!doctype html>
<html lang="cs">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<!--[if lt IE 10]>