Skip to content

Instantly share code, notes, and snippets.

@shoo7830
Created July 28, 2019 13:28
Show Gist options
  • Select an option

  • Save shoo7830/22308202dea7a9fe342d85b8f95452db to your computer and use it in GitHub Desktop.

Select an option

Save shoo7830/22308202dea7a9fe342d85b8f95452db to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/gatimuv
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/redux/4.0.4/redux.js"></script>
<script id="jsbin-javascript">
const INCREMENT = 'INCREMENT';
const DECREMENT = 'DECREMENT';
const increment = (diff) => ({
type: INCREMENT,
diff: diff
});
const decrement = (diff) => ({
type: DECREMENT,
diff: diff
});
const initialState = {
number: 1,
foo: 'bar',
baz: 'qux'
}
function counter(state = initialState, action) {
switch(action.type) {
case INCREMENT:
return {
...state,
number: state.number + action.diff
};
case DECREMENT:
return {
...state,
number: state.number - action.diff
};
default:
return state;
}
}
const { createStore } = Redux;
const store = createStore(counter);
cosnt
</script>
<script id="jsbin-source-javascript" type="text/javascript">const INCREMENT = 'INCREMENT';
const DECREMENT = 'DECREMENT';
const increment = (diff) => ({
type: INCREMENT,
diff: diff
});
const decrement = (diff) => ({
type: DECREMENT,
diff: diff
});
const initialState = {
number: 1,
foo: 'bar',
baz: 'qux'
}
function counter(state = initialState, action) {
switch(action.type) {
case INCREMENT:
return {
...state,
number: state.number + action.diff
};
case DECREMENT:
return {
...state,
number: state.number - action.diff
};
default:
return state;
}
}
const { createStore } = Redux;
const store = createStore(counter);
cosnt</script></body>
</html>
const INCREMENT = 'INCREMENT';
const DECREMENT = 'DECREMENT';
const increment = (diff) => ({
type: INCREMENT,
diff: diff
});
const decrement = (diff) => ({
type: DECREMENT,
diff: diff
});
const initialState = {
number: 1,
foo: 'bar',
baz: 'qux'
}
function counter(state = initialState, action) {
switch(action.type) {
case INCREMENT:
return {
...state,
number: state.number + action.diff
};
case DECREMENT:
return {
...state,
number: state.number - action.diff
};
default:
return state;
}
}
const { createStore } = Redux;
const store = createStore(counter);
cosnt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment