Skip to main content

100 Days of Code day 7

Updated 2 min readMarkdown
Part of series100 days of code
100 Days of Code day 7

I decided to start my day at the computer tackling these error messages I'm receiving from React.

Screen Shot 2022-02-14 at 1.38.23 PM.jpg

Whenever you're rendering an array of React elements, each one must have a unique key prop. I was having issues with displaying a divider with each comment, so I enclosed the content in a react fragment and gave it a key (comment.id).

              {comments.map((comment) => (
                <Fragment key={comment._id}>
                  <Typography
                    sx={{
                      backgroundColor: 'lightblue',
                      padding: '10px',
                      borderRadius: '10px',
                      mt: 1,
                    }}
                  >
                    <div key={comment._id}>
                      {comment.commenter.firstName} {comment.commenter.lastName}{' '}
                      posted on{' '}
                      {moment(comment.createdAt).format('MMMM Do, YYYY')}
                    </div>
                    <div>{comment.comment}</div>
                  </Typography>
                  <Divider sx={{ mt: 1 }} />
                </Fragment>
              ))}

Next warning

Screen Shot 2022-02-14 at 2.13.13 PM.jpg

I believe by default, when you use a Typography element that MUI offers it is a

element. Defining the Typography as a "div" component, I seemed to have fixed the issue.

                  <Typography
                    component="div"
                    sx={{
                      backgroundColor: 'lightblue',
                      padding: '10px',
                      borderRadius: '10px',
                      mt: 1,
                    }}

After fixing the above errors with my application, I spent about an hour reviewing the code that I had written in several components. Then I made another call to the backend to get data about the ticket shown in the browser. Feel free to check out my progress here. It is valentine's day, so I better run to the store and get my flowers and something special for dinner. "Happy wife happy life" - it's a real thing.

About the author

  • Seasoned Professional and recent IT and Web Development Graduate with a deep passion for coding and a drive to accomplish objectives, looking to transition into a career within the Tech industry. Eager to solve problems and relentless in efforts to find solutions. Extensive experience in improving the performance, productivity, efficiency, and profitability of organizational operations. Continually exceeds expectations by building strong relationships and works well with people at all levels of the organization, including stakeholders, customers, vendors, and team members.

No comments yet. Be the first to comment.

100 days of code

Part 7 of 21

In this series I am documenting my daily activities during my journey to find a job as a developer for 100 days . Most of the content will be material I'm learning or working on at the moment.

Up next100 Days of code Day 8Codewars 1st challenge Exclamation marks series #1: Remove an exclamation mark from the end of string my solution function remove (string) { let newString = '' if(string.charAt(string.length - 1) === '!'){ newString = string.slice(0,-1) return...

More from this blog