Display Hogs, Sort Hogs, Filter Hogs#16
Open
Lsimmons98 wants to merge 3 commits intolearn-co-curriculum:masterfrom
Open
Display Hogs, Sort Hogs, Filter Hogs#16Lsimmons98 wants to merge 3 commits intolearn-co-curriculum:masterfrom
Lsimmons98 wants to merge 3 commits intolearn-co-curriculum:masterfrom
Conversation
stephenmckeon
approved these changes
Jun 17, 2024
| @@ -1,12 +1,17 @@ | |||
| import React from "react"; | |||
| import React, {useState} from "react"; | |||
There was a problem hiding this comment.
Suggested change
| import React, {useState} from "react"; | |
| import React, { useState } from "react"; |
Comment on lines
7
to
17
| function App() { | ||
| const [greaseFilter, setGreaseFilter] = useState('') | ||
| const [sortByWeight, setSortByWeight] = useState('') | ||
|
|
||
| return ( | ||
| <div className="App"> | ||
| <Nav /> | ||
| <Nav setGreaseFilter={setGreaseFilter} setSortByWeight={setSortByWeight}/> | ||
| <Menu hogs={hogs} greaseFilter={greaseFilter} sortByWeight={sortByWeight}/> | ||
| </div> | ||
| ); | ||
| } |
There was a problem hiding this comment.
Spacing got a little crazy here!
Comment on lines
+3
to
+5
| const Hog = ({hog, setSelectedHog, selectedHog}) => { | ||
|
|
||
| const handleClick = (e) => { |
There was a problem hiding this comment.
Suggested change
| const Hog = ({hog, setSelectedHog, selectedHog}) => { | |
| const handleClick = (e) => { | |
| const Hog = ({hog, setSelectedHog, selectedHog}) => { | |
| const handleClick = (e) => { |
Comment on lines
+10
to
+19
| if(hog!==selectedHog){ | ||
| return ( | ||
| <div className='pigTile'> | ||
| <div id={hog.name} className='ui eight wide column' onClick={handleClick}> | ||
| <h3>{hog.name}</h3> | ||
| <img className='pigImg' src={hog.image}/> | ||
| </div> | ||
| </div> | ||
| )} else { | ||
| return( |
There was a problem hiding this comment.
What in the world happened here?!
| import React, {useState} from "react"; | ||
| import Hog from './Hog'; | ||
|
|
||
| const Menu = ({ hogs, greaseFilter, sortByWeight}) => { |
There was a problem hiding this comment.
What would be a better approach would be to handle the filtering and sorting in the parent component and only pass in the filtered and sorted set of hogs. Less props and better separation of concerns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Used state to display a list of hogs with options to sort and filter them