Skip to content

Commit

Permalink
Simplify containers declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
slyg committed Jan 28, 2016
1 parent 34fe31f commit 8faaf9c
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 224 deletions.
6 changes: 1 addition & 5 deletions app/scripts/shop/containers/CartContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ import { connect } from 'react-redux';
import Cart from '../components/Cart';
import { removeBookFromCart } from '../actionCreators';

const CartContainer = React.createClass({
render: function(){
return <Cart {...this.props} />;
}
});
const CartContainer = (props) => <Cart {...props} />;

const mapStateToProps = ({cart}) => ({...cart});

Expand Down
6 changes: 1 addition & 5 deletions app/scripts/shop/containers/PayBoxContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import PayBox from '../components/PayBox';

const PayBoxContainer = React.createClass({
render: function(){
return <PayBox {...this.props} />;
}
});
const PayBoxContainer = (props) => <PayBox {...props} />;

const mapStateToProps = ({discount}) => ({...discount});

Expand Down
44 changes: 20 additions & 24 deletions app/scripts/shop/containers/RootContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,31 @@ import BookListContainer from '../containers/BookListContainer';
import CartContainer from '../containers/CartContainer';
import PayBoxContainer from '../containers/PayBoxContainer';

const RootContainer = React.createClass({
const RootContainer = (props) => {

render: function(){
const { hasCart } = props;

const { hasCart } = this.props;

return (
<div className={hasCart ? 'grid-2-1' : 'grid-4-1'}>
<div className='book-list'>
<BookListContainer />
</div>
<div className='cart-box'>
{hasCart ? (
<div>
<div className='cart pbm'>
<CartContainer />
</div>
<div className='offer pbm'>
<PayBoxContainer />
</div>
return (
<div className={hasCart ? 'grid-2-1' : 'grid-4-1'}>
<div className='book-list'>
<BookListContainer />
</div>
<div className='cart-box'>
{hasCart ? (
<div>
<div className='cart pbm'>
<CartContainer />
</div>
<div className='offer pbm'>
<PayBoxContainer />
</div>
) : null}
</div>
</div>
) : null}
</div>
);
</div>
);

}

});
};

const mapStateToProps = ({cart}) => ({
hasCart: (cart.totalPrice > 0)
Expand Down
90 changes: 50 additions & 40 deletions public/shop.bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8faaf9c

Please sign in to comment.