Challenge: Build a Social Media Post Like Button
Swipe to show menu
Task
Create a simple social media post card with a working like counter using the useState hook.
The component must include:
-
A state variable called
likes. Its initial value must be120. -
A heading (
h2element). Its text content must beExploring Iceland. -
A paragraph (
pelement). Its text content must beOne of the most beautiful trips I've ever had. -
Another paragraph (
pelement). It must displayLikes:followed by the current value oflikes. -
A button (
buttonelement). Its text content must beLike Post. -
When the button is clicked increase the
likesstate by1.
Starter Code
Open the starter project below and complete the missing parts of the component.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat