mirror of
https://github.com/Noratrieb/hugos-lieblingsflugzeuge.git
synced 2026-01-16 20:55:05 +01:00
dynamic plane info page
This commit is contained in:
parent
0d1cf198b3
commit
295bdd927c
13 changed files with 132 additions and 12 deletions
20
src/Home.js
20
src/Home.js
|
|
@ -1,15 +1,31 @@
|
|||
import React, {Component} from 'react';
|
||||
import ModelImage from './Plane';
|
||||
import planes from './planes.json'
|
||||
|
||||
class Home extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const favs = planes.filter(isFavPlane);
|
||||
this.state = {
|
||||
favs: favs
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const favs = this.state.favs
|
||||
.map(x => <ModelImage src={x.category + x.img} name={x.name} cat={x.category}/>);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1>Hugos Favoriten</h1>
|
||||
<ModelImage src="f22.png" name="F-22 Raptor"/>
|
||||
<h2>Hugos Favoriten</h2>
|
||||
{favs}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function isFavPlane(plane) {
|
||||
return plane.tags.includes('fav');
|
||||
}
|
||||
|
||||
export default Home;
|
||||
Loading…
Add table
Add a link
Reference in a new issue