Skip to content
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

Update Sidebar.tsx #1

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions library/src/containers/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ export const Sidebar: React.FunctionComponent = () => {
</a>
<ul className="text-sm mt-2">
{messages.map((message, index) => (
<li key={`menu-message-list-${message.name() ?? index}`}>
<li key={`menu-message-list-${message.name() ?? index}`}>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Consider using message.id() instead of message.name() in the key prop for consistency

Since message.name() was replaced with message.id() in the href to fix undefined values, the same change should be applied to the key prop to maintain consistency and prevent potential React reconciliation issues.

       </a>
       <ul className="text-sm mt-2">
         {messages.map((message, index) => (
          <li key={`menu-message-list-${message.id() ?? index}`}>

{/* fixed the message.name() to message.id() to fix undifined name */}
<a
className="flex break-words no-underline text-gray-700 mt-2 hover:text-gray-900"
href={`#message-${message.name()}`}
href={`#message-${message.id()}`}
onClick={() => setShowSidebar(false)}
>
<div className="break-all inline-block">{message.id()}</div>
Expand Down