hugo mag functional components

This commit is contained in:
nora 2021-07-09 11:03:10 +02:00
parent 51646d73fd
commit e7fa62454c
7 changed files with 292 additions and 217 deletions

View file

@ -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) {