mirror of
https://github.com/bendtherules/food-app.git
synced 2026-08-18 13:52:09 +00:00
59 lines
967 B
JavaScript
59 lines
967 B
JavaScript
import Header from './components/Header/header';
|
|
import Categories from './components/Categories';
|
|
import Recipes from './components/Recipes';
|
|
|
|
|
|
import './App.css';
|
|
|
|
class App {
|
|
static recipeURL = './recipes.json';
|
|
|
|
constructor() {
|
|
this.data = undefined;
|
|
this.renderPromise = undefined;
|
|
|
|
this.renderPromise = (
|
|
this
|
|
.initialize()
|
|
.then(
|
|
() => this.render()
|
|
)
|
|
);
|
|
}
|
|
|
|
initialize() {
|
|
|
|
return fetch(App.recipeURL)
|
|
.then((response) => {
|
|
return response.json();
|
|
})
|
|
.then((dataJSON) => {
|
|
this.data = dataJSON;
|
|
});
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
`
|
|
<div className="App">
|
|
${
|
|
Header()
|
|
}
|
|
${
|
|
Categories({
|
|
categories: this.data.categories,
|
|
})
|
|
}
|
|
${
|
|
Recipes({
|
|
recipes: this.data.recipes,
|
|
})
|
|
}
|
|
</div>
|
|
`
|
|
);
|
|
}
|
|
}
|
|
|
|
export default (App);
|