Skip to content

Instantly share code, notes, and snippets.

@AmitKKhanchandani
Created May 26, 2018 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmitKKhanchandani/fd259451541c6fc85ff6c1aaaf729757 to your computer and use it in GitHub Desktop.
Save AmitKKhanchandani/fd259451541c6fc85ff6c1aaaf729757 to your computer and use it in GitHub Desktop.
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