-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleaning comments, unused values and eslint ignores #94
Conversation
Co-authored-by: ThatMegamind <[email protected]> Co-authored-by: michellelin1 <[email protected]>
const renderSeasons = async () => { | ||
const { data } = await NPOBackend.get('/published-schedule/all-seasons'); | ||
if (data.indexOf(curSeason) == -1) { | ||
data.unshift(curSeason); | ||
} | ||
|
||
if (selectedSeason === '') { | ||
setSelectedSeason(curSeason); | ||
const seasonOrder = ['Fall', 'Summer', 'Spring']; | ||
data.sort((a, b) => { | ||
// Compare years first | ||
if (a.split(' ')[1] !== b.split(' ')[1]) { | ||
return b.split(' ')[1] - a.split(' ')[1]; | ||
} else { | ||
return seasonOrder.indexOf(a.split(' ')[0]) - seasonOrder.indexOf(b.split(' ')[0]); | ||
} | ||
}); | ||
|
||
const seasonOrder = ['Fall', 'Summer', 'Spring']; | ||
data.sort((a, b) => { | ||
// Compare years first | ||
if (a.split(' ')[1] !== b.split(' ')[1]) { | ||
return b.split(' ')[1] - a.split(' ')[1]; | ||
} else { | ||
return seasonOrder.indexOf(a.split(' ')[0]) - seasonOrder.indexOf(b.split(' ')[0]); | ||
} | ||
}); | ||
setAllSeasons(data); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'renderSeasons' function makes the dependencies of useEffect Hook (at line 67) change on every render. To fix this, wrap the definition of 'renderSeasons' in its own useCallback() Hook.
setSelectedSeason(curSeason); | ||
} | ||
renderSeasons(); | ||
}, []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React Hook useEffect has missing dependencies: 'curSeason', 'renderSeasons', and 'selectedSeason'. Either include them or remove the dependency array.
closes #92