-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Fixed: #262 Used Async/await syntax #277
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe recent update to the codebase focused on enhancing the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Review Status
Actionable comments generated: 2
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
package-lock.json
is excluded by:!**/*.json
Files selected for processing (1)
- frontend/src/components/ContributorsCard/ContributorCard.js (3 hunks)
Additional comments: 3
frontend/src/components/ContributorsCard/ContributorCard.js (3)
- 9-9: The import statement for
contributorsUrl
is correctly formatted and follows the convention of separating external and internal imports.- 69-81: The map function within the JSX is correctly rendering the list of contributors. However, ensure that the
key
prop is unique and stable, such as a contributor's ID.- 85-91: The anchor tag and button are correctly implemented for navigation to the contributors' details page. Ensure that the URL is correct and that it is accessible.
Verification successful
The URL "https://github.com/shravan20/github-readme-quotes/graphs/contributors" is accessible, returning a 200 HTTP status code, which confirms that the anchor tag and button are implemented correctly for navigation to the contributors' details page.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify the URL is accessible curl -o /dev/null -s -w "%{http_code}\n" https://github.com/shravan20/github-readme-quotes/graphs/contributorsLength of output: 116
useEffect(async () => { | ||
try { | ||
const res = await fetch(contributorsUrl); | ||
|
||
const data = res.json(); | ||
|
||
setListOfContributors(data); | ||
} catch (error) { | ||
console.error("Error fetching contributors:", error); | ||
} | ||
}, []); |
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 useEffect
hook is using an async function directly which is an anti-pattern because it returns a Promise, not a cleanup function. Refactor to define the async function inside the hook and then call it.
- useEffect(async () => {
+ useEffect(() => {
+ async function fetchData() {
try {
const res = await fetch(contributorsUrl);
const data = await res.json(); // Missing await added
setListOfContributors(data);
} catch (error) {
console.error("Error fetching contributors:", error);
}
+ }
+ fetchData();
}, []);
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
useEffect(async () => { | |
try { | |
const res = await fetch(contributorsUrl); | |
const data = res.json(); | |
setListOfContributors(data); | |
} catch (error) { | |
console.error("Error fetching contributors:", error); | |
} | |
}, []); | |
useEffect(() => { | |
async function fetchData() { | |
try { | |
const res = await fetch(contributorsUrl); | |
const data = await res.json(); | |
setListOfContributors(data); | |
} catch (error) { | |
console.error("Error fetching contributors:", error); | |
} | |
} | |
fetchData(); | |
}, []); |
|
||
const classes = useStyles(); | ||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
margin:"10px", | ||
margin: "10px", |
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.
Inline styles are used for the container div. Consider using makeStyles
for consistency and to keep the styling approach uniform across the component.
- <div style={{ display: "flex", margin: "10px", justifyContent: "center", alignItems: "center" }}>
+ <div className={classes.container}>
And add the corresponding style in useStyles
.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
margin: "10px", | |
<div className={classes.container}> |
It's my first pull request. Changed code in ContributorsCard.js file
Summary by CodeRabbit