Skip to content

Commit

Permalink
Dogs are now showing in the home screen
Browse files Browse the repository at this point in the history
novaisea committed Apr 21, 2021
1 parent cf36127 commit 5cd4841
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/dogcard.js
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ class DogCard extends React.Component {
return (
<Card
style={{ width: 320 }}
cover={<NavImage alt={`Dog ${dogID}`} src={this.props.imageURL} to={`/dog/${dogID}`} />}
cover={<NavImage alt={`Dog ${dogID}`} src={this.props.imageURL} to={`/dogs/${dogID}`} />}
hoverable={true}
actions={[
<DogIcon type="like" countLink={this.props.links.likes} selected={this.props.liked}
7 changes: 7 additions & 0 deletions src/components/dogicon.js
Original file line number Diff line number Diff line change
@@ -59,6 +59,13 @@ class DogIcon extends React.Component {
console.log(`${this.props.type} icon error for dog ${this.props.id}`)
});
}

componentDidUpdate(prevProps, prevState){
if (prevState.selected !== this.state.selected) {
//run the handler passed in by the parent component
this.props.handleToggle(this.state.selected);
}
}

render(){
const theme = this.state.selected ? 'filled' : 'outlined';
4 changes: 2 additions & 2 deletions src/components/homegrid.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Col, Row } from 'antd';
import dogCard from './dogcard';
import DogCard from './dogcard';
import { status, json } from '../utilities/requestHandlers';

class HomeGrid extends React.Component {
@@ -30,7 +30,7 @@ class HomeGrid extends React.Component {
return (
<div style={{padding:"10px"}} key={dog.ID}>
<Col span={6}>
<dogCard {...dog} />
<DogCard {...dog} />
</Col>
</div>
)

0 comments on commit 5cd4841

Please sign in to comment.