Flux Architecture: Components/Views

Share this video with your friends

Send Tweet

In this lesson we'll create our initial components using the architecture we've built so far.

jackyon
jackyon
~ 9 years ago

hi, I just curious why sometimes you use es6 class to define the component, and sometimes you just using export default for the component?

i.e: export default (props) => { return ( <div className="col-xs-6 col-sm-4 col-md-3"> <p>{props.item.cost}</p> </div> ) }

why? plz advise.

Joel Hooks
Joel Hooks
~ 9 years ago

React 0.14.x can render a function as a component. It is treated like the render method on a Component

https://egghead.io/lessons/react-building-stateless-function-components-new-in-react-0-14

Altug
Altug
~ 9 years ago

Why are the action methods called with bind? AppActions.addItem.bind(null, props.item) instead of AppActions.addItem(props.item)

Joe Maddalone
Joe Maddalone(instructor)
~ 9 years ago

This is a common JS, not React specific, practice that allows us to pass the function to the child component along with arguments, but letting the child component execute the function when appropriate. AppActions.addItem(props.item) would execute immediately, and in this app, perpetually.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind

Vivek Agarwal
Vivek Agarwal
~ 9 years ago

in app-store.js , _findCart(item) function should return the cartItem :

const _findCartItem = (item) => { return _cartItems.find(cartItem => cartItem.id === item.id); };

this will help during add item. by not returning, it will create new table record instead of just incrementing the item.qty

zainul
zainul
~ 9 years ago

I have some issue Object.assign ? how to resolve this

zainul
zainul
~ 9 years ago

I have some issue Object.assign not a function ? how to resolve this

Mihail Gumennii
Mihail Gumennii
~ 9 years ago

I also have an issue with Object.assign where it throws and error into console "Uncaught TypeError: undefined is not a function" and doesn't render app