The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Flux Architecture: Higher-Order Components

Flux Architecture: Higher-Order Components

5:29
In this lesson we'll shift the responsibility of managing the state of our application over to a higher-order component rather than having each component managing it's own state.
Watch this lesson now
Avatar
egghead.io

In this lesson we'll shift the responsibility of managing the state of our application over to a higher-order component rather than having each component managing it's own state.

Avatar
nader dabit

In app-catalog, how does the catalog keep up with the quantity of items in the cart? I'm not getting that data on the props (the item.qty) from the getCatalog() function of AppStore.getCatalog(). Thanks.

Avatar
Joseph

It all happens here in app-store.js

getCatalog(){
  return _catalog.map(item => {
    return Object.assign( {}, item, _cartItems.find( cItem => cItem.id === item.id))
    })
  },

We map cart item's qty onto the items in a clone of _catalog

In reply to nader dabit
Avatar
nader dabit

Thanks, this cleared it up for me!

In reply to Joseph
Avatar
Keir Beckett

getCatalog(){
return catalog.map(item => {
return Object.assign({}, item, _cartItems.find(cItem => cItem.id === item.id))
})

}
Just wondering if I've written this code down wrong and can't see the mistake because I can't seem to merge the data and get the 'id' property to show up on the '
catalog' data. It exists in the '_cartItems' when I add one to cart.

In reply to Joseph
Avatar
Steven

At 2:06 you replace a function with an invoked function, why does it still work?
Also, on line 7 you simply pass in props but on line 17 you pass in this.props, why the difference? Many thanks for the great series!

In reply to Joseph
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?