Skip to content
This repository was archived by the owner on Jul 24, 2018. It is now read-only.

Commit 813ef4e

Browse files
author
Oscar Lodriguez
committed
refactored with spread operators and fixed resolve inclusions
1 parent ed64ae4 commit 813ef4e

File tree

7 files changed

+8
-14
lines changed

7 files changed

+8
-14
lines changed
File renamed without changes.

app/src/components/product-table.jsx renamed to app/src/components/product-table.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import CategoryRow from './category-row';
33
import ProductRow from './product-row';
44

5-
const ProductTable = ({products, filterText, inStockOnly}) => {
5+
export default ({products, filterText, inStockOnly}) => {
66

77
let rows = [],
88
lastCategory = null;
@@ -32,6 +32,4 @@ const ProductTable = ({products, filterText, inStockOnly}) => {
3232
<tbody>{rows}</tbody>
3333
</table>
3434
);
35-
}
36-
37-
export default ProductTable;
35+
}
File renamed without changes.

app/src/filterable-product-table.jsx renamed to app/src/filterable-product-table.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React from 'react';
1+
import React, {Component} from 'react';
22
import ProductTable from './components/product-table';
33
import SearchBar from './components/search-bar';
44
import products from './models/products';
55

6-
class FilterableProductTable extends React.Component {
6+
class FilterableProductTable extends Component {
77

88
constructor() {
99
super();
@@ -27,14 +27,12 @@ class FilterableProductTable extends React.Component {
2727
return (
2828
<div>
2929
<SearchBar
30-
filterText={this.state.filterText}
31-
inStockOnly={this.state.inStockOnly}
30+
{...this.state}
3231
onUserInput={this.handleUserInput}
3332
/>
3433
<ProductTable
3534
products={products}
36-
filterText={this.state.filterText}
37-
inStockOnly={this.state.inStockOnly}
35+
{...this.state}
3836
/>
3937
</div>
4038
)

app/src/models/products.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
const products = [
1+
export default [
22
{category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"},
33
{category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"},
44
{category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"},
55
{category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"},
66
{category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"},
77
{category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"}
8-
];
9-
10-
export default products;
8+
];

0 commit comments

Comments
 (0)