alcoholoverflowfrontend's Issues
refactor API requests to separate file
Therre are API requests in a bunch of places in the code base. Refactor this into a single adapter or factory and then call ti from wherever
variable called sortedWines that isn't sorted wines
You sort them on the next line...so on this line that is a misleading variable name. I'd just make two variables.
Wine details in Anayltics could probably use the Wine Component
AlcoholOverflowFrontend/src/components/Analytics.js
Lines 24 to 48 in 4933dfa
In here you display both the most reviewed wine and the wine of the week. Couldn't you use the wine
component and just pass in different wines here instead of having a few slightly different iterations on a wine display?
Multi line ternary is really hard to read
AlcoholOverflowFrontend/src/components/Wine.js
Lines 18 to 27 in 4933dfa
Had to do some serious hunting to find the :
. Just extract this to a function and use a normal if
statement. Similar to this: https://facebook.github.io/react/docs/conditional-rendering.html
Don't modify the DOM directly and one component should not modify the DOM of another
AlcoholOverflowFrontend/src/components/WineReviewPage.js
Lines 31 to 32 in 4933dfa
Each component should be reusable. That means that having this component modify the DOM of a child component is not good. In addition to that, you shouldn't be modifying the DOM directly if you can avoid it due to the virtual DOM stuff. Instead reset state appropriately to clear out these variables.
Doing a fetch for the details of a wine from the backend unnecessarily
AlcoholOverflowFrontend/src/components/App.js
Lines 83 to 100 in 4933dfa
So you do a fetch to get the details of a wine given a specific id. Then grab that to increment/decrement the upvotes. There is no need to do that intial fetch to get the wine details. You've already done by fetching all wine data. Instead of just passing in the id
into this function you can pass the entire wine
object in. That way all you need to do is do the PUT request.
Why have different elements for value and text
AlcoholOverflowFrontend/src/components/WineList.js
Lines 26 to 43 in 4933dfa
they look to be identical every time? Why not just have one value
function named "getMostReviewed" just sorts
AlcoholOverflowFrontend/src/components/App.js
Lines 139 to 144 in 4933dfa
So you use this function to display the most reviewed wines, but the function itself doesn't do anything other than return a sorted version of the wines. A better function name would be just sortedWinesByReviews
Finding Avg rating could have been done with map
AlcoholOverflowFrontend/src/components/App.js
Lines 126 to 134 in 4933dfa
This line can be made a bit simpler using map
instead of that for
loop. Any time you feel yourself making a blank array, then putting stuff into it there is usually an iterator you can use
in Analytics getMostReviewed returns an array containing 1 item, just grab that item instead of constantly doing [0]
So you slice the array to just have one thing in it. Then throughout the component you are doing mostreviewed[0]
if you feel yourself doing that a lot, just when you slice, grab the 0th element right there.
Repeated Code is dying to be converted into functions
AlcoholOverflowFrontend/src/components/App.js
Lines 63 to 76 in 4933dfa
These two occurrences plus the one above that sorts them is dying to be put into a function! Also I assume you want them to be sorted no matter the filter?
Try and stay away from inline CSS
Put this into a normal site CSS
data and newAry are not very descriptive variable names
AlcoholOverflowFrontend/src/components/App.js
Lines 124 to 125 in 4933dfa
What actually will be in newAry? What is in data?
Weird Indentation
AlcoholOverflowFrontend/src/components/Homepage.js
Lines 19 to 22 in 4933dfa
It's small, but it matters!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.