Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
JS Bin redux counter example // source https://jsbin.com/gugexik
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="redux counter example">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://fb.me/react-15.1.0.js"></script>
<script src="https://fb.me/react-dom-15.1.0.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 _Redux = Redux;
var createStore = _Redux.createStore;
</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 {createStore} = Redux;</script></body>
</html>
'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 _Redux = Redux;
var createStore = _Redux.createStore;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment