scrimba
React Bootcamp Course
Plain JS Redux - Overview
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Plain JS Redux - Overview
AboutCommentsNotes
Plain JS Redux - Overview
Expand for more info
index.js
run
preview
console
const redux = require("redux")
const initialState = {
count: 0
}

function reducer(state=initialState, action) {
switch(action.type) {
case "INCREMENT":
return {
count: state.count + 1
}
case "DECREMENT":
return {
count: state.count - 1
}
default:
return state
}
}

const store = redux.createStore(reducer)

store.subscribe(() => {
console.log(store.getState())
})

store.dispatch({type: "INCREMENT"})
store.dispatch({type: "INCREMENT"})
store.dispatch({type: "DECREMENT"})
Console
/index.html
-1:50