Published onSeptember 20, 2023
What is State?
State is a updatable variable in React/Next js that will cause a rerender of the component
Define state in functional component use useState()
in this example we have state namely 'name'. We can update the name value use setName
So when updateName function is executed, the name value will updated from ' ' to 'Bayu'
State in client site event. So, you can't use it on server component. Make sure to add 'use client' on the top your component.
Hope this helps!
Hi, kindly leave a like and comment if you got new insight! 🔥