mirror of
https://github.com/Noratrieb/hugos-lieblingsflugzeuge.git
synced 2026-01-16 20:55:05 +01:00
hugo mag functional components
This commit is contained in:
parent
51646d73fd
commit
e7fa62454c
7 changed files with 292 additions and 217 deletions
37
src/Home.js
37
src/Home.js
|
|
@ -1,32 +1,23 @@
|
|||
import React, {Component} from 'react';
|
||||
import React from 'react';
|
||||
import ModelImage from './PlanePreview';
|
||||
import planes from './planes.json'
|
||||
|
||||
class Home extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const favs = planes.filter(isFavPlane);
|
||||
this.state = {
|
||||
favs: favs
|
||||
}
|
||||
}
|
||||
const Home = () => {
|
||||
const favs = planes.filter(isFavPlane)
|
||||
.map(p => <ModelImage src={p.category + p.img} name={p.name} cat={p.category} key={p.category + p.name}/>);
|
||||
|
||||
render() {
|
||||
const favs = this.state.favs
|
||||
.map(x => <ModelImage src={x.category + x.img} name={x.name} cat={x.category} key={x.category + x.name}/>);
|
||||
const all = planes
|
||||
.map(x => <ModelImage src={x.category + x.img} name={x.name} cat={x.category} key={x.category + x.name}/>);
|
||||
|
||||
const all = planes
|
||||
.map(x => <ModelImage src={x.category + x.img} name={x.name} cat={x.category} key={x.category + x.name}/>);
|
||||
return (
|
||||
<div>
|
||||
<h2>Hugos Favoriten</h2>
|
||||
{favs}
|
||||
<h2>Alle Flugzeuge</h2>
|
||||
{all}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2>Hugos Favoriten</h2>
|
||||
{favs}
|
||||
<h2>Alle Flugzeuge</h2>
|
||||
{all}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isFavPlane(plane) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue