Created
April 17, 2017 01:27
-
-
Save wired00/f2ff8efc43c42a093ade165dd39a5f00 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/tazelul
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"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.7/TweenMax.min.js"></script> | |
<script src="https://unpkg.com/expect/umd/expect.min.js"></script></body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js"></script> | |
<script src="https://unpkg.com/react@15/dist/react.js"></script> | |
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"></script> | |
</head> | |
<body> | |
<div id='root'></div> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
var counter = function counter(state, action) { | |
if (state === undefined) state = 0; | |
switch (action.type) { | |
case 'INCREMENT': | |
return state + 1; | |
case 'DECREMENT': | |
return state - 1; | |
default: | |
return state; | |
} | |
}; | |
var Counter = function Counter(_ref) { | |
var value = _ref.value; | |
return React.createElement( | |
'h1', | |
null, | |
value | |
); | |
}; | |
var _Redux = Redux; | |
var createStore = _Redux.createStore; | |
var store = createStore(counter); | |
var render = function render() { | |
ReactDOM.render(React.createElement(Counter, { value: store.getState() }), document.getElementById('root')); | |
}; | |
store.subscribe(render); | |
render(); | |
</script> | |
<script id="jsbin-source-html" type="text/html"> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.7/TweenMax.min.js"><\/script> | |
<script src="https://unpkg.com/expect/umd/expect.min.js"><\/script></body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/3.6.0/redux.js"><\/script> | |
<script src="https://unpkg.com/react@15/dist/react.js"><\/script> | |
<script src="https://unpkg.com/react-dom@15/dist/react-dom.js"><\/script> | |
</head> | |
<body> | |
<div id='root'></div> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">const counter = (state = 0, action) => { | |
switch (action.type) { | |
case 'INCREMENT': | |
return state + 1; | |
case 'DECREMENT': | |
return state - 1; | |
default: | |
return state; | |
} | |
} | |
const Counter = ({ value }) => ( | |
<h1>{value}</h1> | |
); | |
const { createStore } = Redux; | |
const store = createStore(counter); | |
const render = () => { | |
ReactDOM.render( | |
<Counter value={store.getState()} />, | |
document.getElementById('root') | |
); | |
}; | |
store.subscribe(render); | |
render(); | |
</script></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
'use strict'; | |
var counter = function counter(state, action) { | |
if (state === undefined) state = 0; | |
switch (action.type) { | |
case 'INCREMENT': | |
return state + 1; | |
case 'DECREMENT': | |
return state - 1; | |
default: | |
return state; | |
} | |
}; | |
var Counter = function Counter(_ref) { | |
var value = _ref.value; | |
return React.createElement( | |
'h1', | |
null, | |
value | |
); | |
}; | |
var _Redux = Redux; | |
var createStore = _Redux.createStore; | |
var store = createStore(counter); | |
var render = function render() { | |
ReactDOM.render(React.createElement(Counter, { value: store.getState() }), document.getElementById('root')); | |
}; | |
store.subscribe(render); | |
render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment