scrimba
Redux Fundamentals With React
Learning Takeaways
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

Learning Takeaways
AboutCommentsNotes
Learning Takeaways
Expand for more info
store
index.js
run
preview
console
import { createStore } from 'redux'

const house = {
type: 'condo',
rooms: [
{id: 1, type: 'Living Room'},
{id: 2, type: 'Dining Room'},
{id: 3, type: 'Bathroom'}
],
doorsOpen: {
backDoor: false,
frontDoor: true
},
temp: 'Calculating...'
}

const reducer = (state = house, action) => {
if (action.type === 'ADD_ROOM') {
return Object.assign({}, state, {
rooms: state.rooms.concat(action.payload)
})
}

if (action.type === 'GET_TEMP') {
return Object.assign({}, state, {
temp: action.payload
})
}
return state
}

const store = createStore(reducer)

export default store


// Redux, Context, and Composition
// https://dev.to/singhshemona/state-management-with-react-when-to-use-what-3nhm
Console
/index.html
-1:46