UI Controllers
Stores
Basket
Products
List
Account Options
Products
User
Account
Staff
Meet the staff
D
i
s
p
a
t
c
h
e
r
A
c
t
i
o
n
C
r
e
a
t
o
r
s
{
type: 'START_SALE'
}
{
type: 'ADD_STAFF',
name: 'Phoebe Jones'
}
Actions
P
a
g
e
UI Events
Docs: https://redux.js.org/
UI Controllers
Store
Basket
Products
List
Account Options
Products
User
Account
Staff
Meet the staff
A
c
t
i
o
n
C
r
e
a
t
o
r
s
{
type: 'START_SALE'
}
{
type: 'ADD_STAFF',
name: 'Phoebe Jones'
}
Actions
P
a
g
e
UI Events
import { deleteCar } from './actions'
// Here 'state' is the whole redux store
const mapStateToProps = (state, componentsProps) => ({
items: state.cars // the cars in the state become the items in the component's props
})
// Can be an object or a function. (Object recommended)
// These methods get access to 'dispatch'
// which is the only way to ssend signals to the store
const mapDispatchToProps = {
deleteCar // this method gets passed into props and can then be called
}
// connect creates a HOC
const ConnectedComponent = connect(
mapStateToProps,
mapDispatchToProps
)(Component)
export default ConnectedComponent
export const deleteCar = (id) => ({
type: 'DELETE_CAR',
payload: {
id,
}
})
Action Creator
Component