made with esnextbin
Created
April 5, 2016 09:36
-
-
Save Cmdv/d959a0e2bd128aa513ac950d05b091ac to your computer and use it in GitHub Desktop.
esnextbin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore } from 'redux' | |
import React from 'react' | |
import ReactDOM from 'react-dom' | |
const Counter = ({ value, onAdd }) => ( | |
<div> | |
<h1>{value}</h1> | |
<button onClick={onAdd}>+</button> | |
</div> | |
); | |
const counter = (state = 0, action) => { | |
if (action.type === 'inc') { | |
return state + 1 | |
} | |
return state | |
} | |
const store = createStore(counter) | |
const render = () => { | |
ReactDOM.render( | |
<Counter | |
value={store.getState()} | |
onAdd={() => store.dispatch({ type: 'inc' })} | |
/>, | |
document.body | |
) | |
} | |
render() | |
store.subscribe(render) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"redux": "3.2.1", | |
"react": "0.14.7", | |
"react-dom": "0.14.7" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var _redux = require('redux'); | |
var _react = require('react'); | |
var _react2 = _interopRequireDefault(_react); | |
var _reactDom = require('react-dom'); | |
var _reactDom2 = _interopRequireDefault(_reactDom); | |
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | |
var Counter = function Counter(_ref) { | |
var value = _ref.value; | |
var onAdd = _ref.onAdd; | |
return _react2.default.createElement( | |
'div', | |
null, | |
_react2.default.createElement( | |
'h1', | |
null, | |
value | |
), | |
_react2.default.createElement( | |
'button', | |
{ onClick: onAdd }, | |
'+' | |
) | |
); | |
}; | |
var counter = function counter() { | |
var state = arguments.length <= 0 || arguments[0] === undefined ? 0 : arguments[0]; | |
var action = arguments[1]; | |
if (action.type === 'inc') { | |
return state + 1; | |
} | |
return state; | |
}; | |
var store = (0, _redux.createStore)(counter); | |
var render = function render() { | |
_reactDom2.default.render(_react2.default.createElement(Counter, { | |
value: store.getState(), | |
onAdd: function onAdd() { | |
return store.dispatch({ type: 'inc' }); | |
} | |
}), document.body); | |
}; | |
render(); | |
store.subscribe(render); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment