Created
January 5, 2018 21:11
-
-
Save xavierartot/f671b797f1f37f780781dde645fbc110 to your computer and use it in GitHub Desktop.
load data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dataStore.js | |
const products = { | |
product1 : {category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"}, | |
product2 : {category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"}, | |
product3 : {category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"}, | |
product4 : {category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"}, | |
product5 : {category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"}, | |
product6 : {category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"} | |
}; | |
export default products; | |
import React, { Component } from 'react'; | |
import FilterableProductTable from './FilterableProductTable.js' | |
import DataLoad from './dataStore.js'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.loadDataStore = this.loadDataStore.bind(this); | |
this.state = { | |
data: {}, | |
} | |
} | |
loadDataStore () { | |
this.setState({ | |
data: DataLoad | |
}); | |
} | |
render() { | |
console.log(this.loadDataStore); | |
return ( | |
<div> | |
<FilterableProductTable data={this.loadDataStore}/> | |
</div> | |
) | |
} | |
} | |
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dataStore.js | |
const products = { | |
product1 : {category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"}, | |
product2 : {category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"}, | |
product3 : {category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"}, | |
product4 : {category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"}, | |
product5 : {category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"}, | |
product6 : {category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"} | |
}; | |
export default products; | |
import React, { Component } from 'react'; | |
import FilterableProductTable from './FilterableProductTable.js' | |
import DataLoad from './dataStore.js'; | |
class App extends Component { | |
constructor() { | |
super(); | |
this.loadDataStore = this.loadDataStore.bind(this); | |
this.state = { | |
data: {}, | |
} | |
} | |
loadDataStore () { | |
this.setState({ | |
data: DataLoad | |
}); | |
} | |
render() { | |
console.log(this.loadDataStore); | |
return ( | |
<div> | |
<FilterableProductTable data={this.loadDataStore}/> | |
</div> | |
) | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment