-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
[#395] Fix some sonar cloud issues #452
Changes from 6 commits
22567e5
758facb
67133af
886aa18
88c7d9e
d2e9674
faa1803
f730b29
e33e668
2a6e8dc
cc6a34a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,13 +11,19 @@ const InputGrid: FC<InputGridProps> = ({ children, className }) => { | |
|
||
return ( | ||
<Row gutter={[16, 0]} className={className}> | ||
{childElements.map((child, index) => ( | ||
<Col key={index} xs={24} sm={24} md={24} lg={12}> | ||
{childElements.map((child) => ( | ||
<Col key={getKey(child)} xs={24} sm={24} md={24} lg={12}> | ||
{child} | ||
</Col> | ||
))} | ||
</Row> | ||
); | ||
}; | ||
|
||
// Function to generate unique keys based on child content | ||
const getKey = (child: React.ReactNode): string => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @panagiotisbellias can you please share more about this approach. For example any articles, docs etc There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this project we don't write helper functions inside a component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@lifeparticle To avoid using array indices as keys, I generated unique keys for each child element using a unique identifier associated with each child element. In the getKey function, I generated the key based on the content of each child element. This ensures that each child has a unique key without relying on array indices. Probably this needs testing too when above information is provided.
I'm sorry, didn't notice. Please confirm that the correct location for the helper function (after testing it) should be Thanks, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @panagiotisbellias Thank you for the explanation. Can you please check the official doco here, https://react.dev/learn/rendering-lists I'm not sure if this is the right approach to generate a key. Please put it in the same directory Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lifeparticle Indeed this is not the right approach to generate a key. This has to be done per case according to what attributes each list's object have like id, uuid etc. But here is very generic so I suggest to keep this sonar issue until a better solution comes out |
||
// Example: Generate a unique key based on child content | ||
return `${child}`; | ||
}; | ||
|
||
export default InputGrid; |
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.
@panagiotisbellias have you tested this code?
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.
@lifeparticle No, please confirm that I can run the application navigating to the ui directory and running
npm install
. Also, please provide the proper NodeJS version so I can test the codeThanks,
Panagiotis
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.
@panagiotisbellias please follow the steps here, https://github.com/lifeparticle/binarytree/blob/main/ui/CONTRIBUTING.md
Thanks
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.
@lifeparticle I'm on it, thanks
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.
@lifeparticle I'm facing issues installing yarn. The v3.6.1 cannot be found either from Windows or WSL (Ubuntu 22.04)
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.
@panagiotisbellias make sure that you're inside the
ui
folderThere 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.
Ok, now I did it with some warnings though. I see that the title is gone this way so i'm adding the correct title in the html element. This is good to be configurable though reading the title from the previous location
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.
@lifeparticle Hi, if more actions are needed by me please inform me or close this PR. Thanks
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.
@panagiotisbellias, please pull the latest from the main and review your changes. For example,
ui/src/components/Layouts/PageGrid/PageGrid.tsx
ui/index.html
Thanks
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.
@lifeparticle Latest changes generated merge confilcts with my side branch, so I'm closing this pull request and open a new one for the same issue when time
Thanks