Last active
June 17, 2018 20:19
-
-
Save drenther/7cfa46e52bfd18680797c04349c4c6da to your computer and use it in GitHub Desktop.
Presentational Components of react-ssr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Helmet } from 'react-helmet'; | |
import { Link } from 'react-router-dom'; | |
import Loading from './Loading'; | |
const Home = ({ loading, data }) => ( | |
<div className="home container"> | |
<Helmet> | |
<title>FavMovies - Home</title> | |
</Helmet> | |
{loading ? <Loading /> : <Table movies={data} />} | |
</div> | |
); | |
const Table = ({ movies }) => ( | |
<table className="table table-striped"> | |
<thead> | |
<tr> | |
<th>Movie</th> | |
<th>Rating</th> | |
</tr> | |
</thead> | |
<tbody>{movies.map(movie => <Row key={movie.id} {...movie} />)}</tbody> | |
</table> | |
); | |
const Row = ({ id, title, rating }) => ( | |
<tr> | |
<td> | |
<Link to={`/movie/${id}`}>{title}</Link> | |
</td> | |
<td>{rating}</td> | |
</tr> | |
); | |
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const Loading = ({ size }) => <div className={size === 'lg' ? 'loading-lg' : 'loading'} />; | |
export default Loading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Helmet } from 'react-helmet'; | |
import { Link } from 'react-router-dom'; | |
import Loading from './Loading'; | |
const Movie = ({ loading, data }) => ( | |
<div className="post container"> | |
<Helmet> | |
<title>FavMovies - {loading ? 'Movie' : data.title}</title> | |
</Helmet> | |
{loading ? ( | |
<Loading /> | |
) : ( | |
<div className="card"> | |
<div className="card-header"> | |
<div className="card-title h5">{data.title}</div> | |
<div className="card-subtitle text-gray">IMDB Rating - {data.rating}</div> | |
</div> | |
<div className="card-body">{data.plot}</div> | |
<div className="card-footer"> | |
<Link to="/" className="btn btn-primary"> | |
Back to Home | |
</Link> | |
</div> | |
</div> | |
)} | |
</div> | |
); | |
export default Movie; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
const NoMatch = () => <div className="route">No such route!!</div>; | |
export default NoMatch; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment