Console warnings (Closes #7) #31
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes console warnings about missing keys in React lists and removes duplicate footer element from the Home page. This resolves issue number 7.
Type of Change
Bug fix (non breaking change which fixes an issue)
Code refactoring (no functional changes)
How Has This Been Tested
Ran the dev server and verified console warnings are resolved. Checked that all list components render correctly with proper keys. Verified the Home page displays correctly with single footer.
File Changes made in this PR:
ChatRoom.tsx: Changed message list key from array index to unique identifier using msg.id or a combination of timestamp and userId. This prevents React key warnings when messages are added or removed from the list.
CheckInModal.tsx: Changed confetti animation key from plain index to prefixed string format using confetti followed by the index number. This ensures unique keys for the animated elements.
Home.tsx: Removed duplicate footer element. The page was rendering both an inline footer section and a separate Footer component, causing duplicate content to appear at the bottom of the page.
Learning Outcomes
Learned about React key best practices. Using array indices as keys can cause issues with component state and reconciliation when items are reordered, added, or removed. Unique identifiers should be used whenever possible to help React efficiently update the DOM.