Skip to content

Commit

Permalink
Challenge and Code: Card Component
Browse files Browse the repository at this point in the history
  • Loading branch information
15Dkatz committed Oct 24, 2022
1 parent 33a8f5f commit ec34051
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions evens-or-odds/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fetchNewDeck } from '../actions/deck';
import fetchStates from '../reducers/fetchStates';
import Instructions from './Instructions';
import DrawCard from './DrawCard';
import Card from './Card';

class App extends Component {
startGame = () => {
Expand Down Expand Up @@ -34,6 +35,8 @@ class App extends Component {
<br />
<DrawCard />
<hr />
<Card />
<hr />
<button onClick={this.props.cancelGame}>Cancel Game</button>
</div>
) : (
Expand Down
19 changes: 19 additions & 0 deletions evens-or-odds/src/components/Card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { connect } from 'react-redux';

const Card = ({ cards }) => {
if (!cards[0]) return null;

const { value, suit, image } = cards[0];

return (
<div>
<h3>{value} of {suit}</h3>
<img src={image} alt='card-image' />
</div>
);
}

export default connect(
({ deck: { cards }}) => ({ cards })
)(Card);

0 comments on commit ec34051

Please sign in to comment.