Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Interactive Comments Section with React, React Context and BEM

#bem#react
kreyson 60

@kreyson999

Desktop design screenshot for the Interactive comments section coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
3intermediate
View challenge

Design comparison


SolutionDesign

Solution retrospective


What should i do to make this code "cleaner"? Is React Context good solution for this app? What should i do to save this data to localStorage immediately, because i'm saving this data after setState and we know that setState is asynchronous so saved data isn't always current?

Community feedback

Adarsh 1,560

@adram3l3ch

Posted

Hey yoy did great 👍. You can solve the local storage problem using useEffect.

useEffect(()=>
  localStorage.setItem
  ("comments",JSON.stringify(state))
  ,state)

Marked as helpful

1

kreyson 60

@kreyson999

Posted

@adram3l3ch thank you so much, you really helped me!

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord