Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created October 9, 2018 08:40
Show Gist options
  • Save amandeepmittal/d82466c8ae036fdf43706f04719d0607 to your computer and use it in GitHub Desktop.
Save amandeepmittal/d82466c8ae036fdf43706f04719d0607 to your computer and use it in GitHub Desktop.
// Details.js
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
import { Col, Row, Container } from '../../components/Grid';
import Jumbotron from '../../components/Jumbotron';
import API from '../../utils/API';
class Detail extends Component {
state = {
book: {}
};
componentDidMount() {
API.getBook(this.props.match.params.id)
.then(res => this.setState({ book: res.data }))
.catch(err => console.log(err));
}
render() {
return (
<Container fluid>
<Row>
<Col size="md-12">
<Jumbotron>
<h1>
{this.state.book.title} by {this.state.book.author}
</h1>
</Jumbotron>
</Col>
</Row>
<Row>
<Col size="md-2">
<Link to="/">← Back to Authors</Link>
</Col>
</Row>
</Container>
);
}
}
export default Detail;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment