Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Redux Quickstart
<!DOCTYPE html>
<script src=''></script>
<h1>Redux Quickstart<h1>
<h2>Count: <span id="counter">0</span></h2>
<button onclick="increment();">+</button>
<button onclick="decrement();">-</button>
function changeState(state = 0, action) {
switch(action.type) {
return state + 1;
return state - 1;
return state;
let store = Redux.createStore(changeState);
store.subscribe( () => {
document.getElementById('counter').innerHTML = store.getState();
function increment() {
store.dispatch({ type: 'INCREMENT' });
function decrement() {
store.dispatch({ type: 'DECREMENT' });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.