basic frontend demo with react and redux
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import React, { Component } from "react";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
import ItemCard from "../itemcard/ItemCard";
|
||||
import "./ItemsContainer.css";
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
items: state.items
|
||||
};
|
||||
};
|
||||
|
||||
class ItemContainer extends Component {
|
||||
renderItems() {
|
||||
let items = this.props.items;
|
||||
return items.map((item, index) => {
|
||||
return <ItemCard {...item} key={index} />;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<div className="items-list">{this.renderItems()}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
export default connect(mapStateToProps)(ItemContainer);
|
||||
Reference in New Issue
Block a user