scrimba
Redux Fundamentals With React
Challenge: Using Redux With React
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

Challenge: Using Redux With React
AboutCommentsNotes
Challenge: Using Redux With React
Expand for more info
store
index.js
run
preview
console
import { createStore } from 'redux'

const solarSystem = {
star: 'sun',
planets: [
{id: 1, name: 'Mercury'},
{id: 2, name: 'Venus'},
{id: 3, name: 'Earth'},
{id: 4, name: 'Mars'}
],
constellationsVisible: {
orion: false,
pegasus: true
}
}

const reducer = (state = solarSystem, action) => {
if (action.type === 'ADD_PLANET') {
return Object.assign({}, state, {
planets: state.planets.concat(action.payload)
})
}
return state
}

const store = createStore(reducer)

export default store
Console
/index.html
-2:50