New Nav Bar implemented

This commit is contained in:
Luis Fernando Molina committed 2018-09-04 15:21:33 +02:00
1 parent c43ba98638
commit eab34e4da2
10 files changed
+219 -62

No files matched your search

+45 -9
View File
@@ -1,14 +1,50 @@
import React from 'react'
import React, { Component } from 'react'
import axios from 'axios'
import { Link } from 'react-router-dom'
import Pokeball from '../pokeball.png'
const Search = () => {
return (
<div>
<div className="container">
<h4 className="center">Search</h4>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Recusandae repudiandae repellat illo magni eligendi cupiditate voluptates eius nam voluptate. Incidunt nihil ullam quae quia officia quaerat, deserunt eligendi explicabo totam?</p>
class Search extends Component {
state = {
posts: []
}
componentDidMount(){
axios.get('https://jsonplaceholder.typicode.com/posts/')
.then(res => {
console.log(res);
this.setState({
posts: res.data.slice(0,10)
});
})
}
render(){
const { posts } = this.state
const postList = posts.length ? (
posts.map(post => {
return (
<div className="post card" key={post.id}>
<img src={Pokeball} alt="A Pokeball" />
<div className="card-content">
<Link to={'/' + post.id}>
<span className="card-title red-text">{post.title}</span>
</Link>
<p>{post.body}</p>
</div>
</div>
)
})
) : (
<div className="center">No posts to show</div>
);
return (
<div>
<div className="container home">
<h4 className="center">Search</h4>
{postList}
</div>
</div>
</div>
)
)
}
}
export default Search