Skip to content

Commit

Permalink
Completed context
Browse files Browse the repository at this point in the history
  • Loading branch information
jin-co committed Nov 1, 2023
1 parent 4c251ff commit 2d6f1e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
9 changes: 7 additions & 2 deletions React/test-feed/src/components/FeedItem.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useContext } from 'react'
import { FaTimes } from 'react-icons/fa'
import { FaEdit, FaTimes } from 'react-icons/fa'
import { Card } from './shared/Card'
import FeedContext from '../context/FeedContext'

export const FeedItem = ({ feed }) => {
const { deleteFeed } = useContext(FeedContext)
const { deleteFeed, editFeed } = useContext(FeedContext)
return (
<Card>
<div className="num-display">{feed.rating}</div>
Expand All @@ -13,6 +13,11 @@ export const FeedItem = ({ feed }) => {
className="close"
onClick={() => deleteFeed(feed.id)}
/>
<FaEdit
color="blue"
className="edit"
onClick={() => editFeed()}
/>
<div className="text-display">{feed.text}</div>
{/* <button onClick={onClick}>click</button> */}
</Card>
Expand Down
6 changes: 4 additions & 2 deletions React/test-feed/src/components/FeedStat.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, { useEffect } from 'react'
import React, { useContext, useEffect } from 'react'
import FeedContext from '../context/FeedContext'

export const FeedStat = ({ feed }) => {
export const FeedStat = () => {
const { feed } = useContext(FeedContext)
let avg = feed.reduce((acc, cur) => {
return acc + cur.rating
}, 0) / 3
Expand Down

0 comments on commit 2d6f1e4

Please sign in to comment.