-
Notifications
You must be signed in to change notification settings - Fork 48
Fix React key warnings in Blogs and resolve zoom plugin dependencies #249
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for kmesh-net ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Welcome @Payel-Manna! It looks like this is your first PR to kmesh-net/website 🎉 |
Summary of ChangesHello @Payel-Manna, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request primarily focuses on improving the stability and maintainability of the project by resolving React Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request successfully addresses the React key warnings and resolves the private zoom plugin dependency. The changes in src/components/Blogs/index.js
correctly use unique identifiers for keys, which is great. However, I found a critical issue where a non-JSX comment was added, which will break the build. I've also suggested an improvement for variable naming and key selection for better code clarity and robustness. Additionally, the changes in package.json
include updates to many dependencies beyond what was mentioned in the PR description. While this might be intentional, it significantly expands the scope of the change and potential for unintended side effects. It would be good to acknowledge these wider dependency updates in the description.
src/components/Blogs/index.js
Outdated
<div className="right"> | ||
{blogPosts.slice(0, 3).map((item, index) => ( | ||
<div key={index} className="viewBlogContainer"> | ||
<div key={item.metadata.permalink} className="viewBlogContainer">/* Better to use unique identifer than index as key */ |
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.
An invalid C-style comment (/* ... */
) has been added within the JSX. This will cause a syntax error and break the React application. Comments inside JSX should be enclosed in curly braces and asterisks like {/* this is a comment */}
. Since this comment just explains a standard React practice, it's better to remove it entirely for cleaner code.
<div key={item.metadata.permalink} className="viewBlogContainer">/* Better to use unique identifer than index as key */ | |
<div key={item.metadata.permalink} className="viewBlogContainer"> |
{(item.metadata?.authors || []).map((item) => ( | ||
<a href={item.url} target="_blank"> | ||
<a key={item.name} href={item.url} target="_blank" rel="noreferrer"> | ||
{item.name} | ||
</a> | ||
))} |
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.
There are a couple of improvements that can be made here for clarity and robustness:
- The variable
item
is being reused in the innermap
function, which shadows theitem
variable from the outermap
. This can make the code harder to read. It's better to use a more descriptive name likeauthor
. - Using
item.name
as akey
is good, but author names might not be unique within a single post. Theitem.url
is more likely to be a unique identifier. Using a guaranteed unique value for the key is a React best practice.
{(item.metadata?.authors || []).map((item) => ( | |
<a href={item.url} target="_blank"> | |
<a key={item.name} href={item.url} target="_blank" rel="noreferrer"> | |
{item.name} | |
</a> | |
))} | |
{(item.metadata?.authors || []).map((author) => ( | |
<a key={author.url} href={author.url} target="_blank" rel="noreferrer"> | |
{author.name} | |
</a> | |
))} |
@jayesh9747 @kevin-wangzefeng
✅ Ready for review. |
Fix React key warnings and replace private zoom plugin with public package
Description
This pull request addresses two issues:
React
key
warnings in the Blogs componentkey
props for mapped elements, including the authors list.Netlify build failure due to private zoom plugin
plugin-image-zoom
) via SSH.docusaurus-plugin-image-zoom
.docusaurus.config.js
to reference the plugin by its full name.package.json
andyarn.lock
accordingly.Solution