dummy html cleaned
This commit is contained in:
1 parent
153dbf9663
commit
327bfcc038
7 files changed
+3
-219
No files matched your search
@@ -1,45 +1,15 @@
|
||||
import React, { Component } from 'react'
|
||||
import axios from 'axios'
|
||||
import { Link } from 'react-router-dom'
|
||||
import Pokeball from '../pokeball.png'
|
||||
|
||||
class Search extends Component {
|
||||
state = {
|
||||
posts: []
|
||||
}
|
||||
componentDidMount(){
|
||||
axios.get('https://jsonplaceholder.typicode.com/posts/')
|
||||
.then(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>
|
||||
);
|
||||
|
||||
render(){
|
||||
return (
|
||||
<div>
|
||||
<div className="container home">
|
||||
<h4 className="center">Search</h4>
|
||||
{postList}
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user