This is a solution to the Interactive comments section challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic
Users should be able to:
- View the optimal layout for the app depending on their device's screen size
- See hover states for all interactive elements on the page
- Create, Read, Update, and Delete comments and replies
- Upvote and downvote comments
- Bonus: If you're building a purely front-end project, use
localStorageto save the current state in the browser that persists when the browser is refreshed. - Bonus: Instead of using the
createdAtstrings from thedata.jsonfile, try using timestamps and dynamically track the time since the comment or reply was posted.
- Solution URL: solution URL
- Live Site URL: live site URL
- React - JS library
- Tailwind CSS
- Redux toolkit & React redux for state management
editComment(state,action){const{ index, text, parentIndex }=action.payload;letcommentsCopy=[...state.comments];Number.isInteger(parentIndex)
? (commentsCopy[parentIndex].replies[index].content=text)
: (commentsCopy[index].content=text);state.comments=[...commentsCopy];}useEffect(()=>{if(mode==="reply"){setInput(`@${replyingTo} `);setInputRef();}},[mode]);- WhatsApp - here
- LinkedIn - here
- Frontend Mentor - @yourusername
