Skip to content

Commit

Permalink
SongDetail page & load data from apollo
Browse files Browse the repository at this point in the history
  • Loading branch information
patw0929 committed Dec 19, 2018
1 parent 6c885e0 commit 788a2e5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions client/components/SongDetail.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
import React, { Component } from 'react';
import { graphql } from 'react-apollo';
import { Link } from 'react-router';

import query from '../queries/fetchSong';

class SongDetail extends Component {
render() {
const { loading, song } = this.props.data;

if (loading || !song) {
return <div>Loading...</div>;
}

return (
<div>
<h3>Song Detail</h3>
<Link to="/">Back</Link>

<h3>{song.title}</h3>
</div>
);
}
}

export default SongDetail;
export default graphql(query, {
options: props => {
return {
variables: {
id: props.params.id,
},
};
},
})(SongDetail);
2 changes: 1 addition & 1 deletion client/components/SongList.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SongList extends Component {
return this.props.data.songs.map(({ id, title }) => {
return (
<li key={id} className="collection-item">
{title}
<Link to={`/songs/${id}`}>{title}</Link>

<i
className="material-icons"
Expand Down

0 comments on commit 788a2e5

Please sign in to comment.