State - Next Js App Directory 13.4

Published onSeptember 20, 2023
119Views
1min read
1Comment
State - Next Js App Directory 13.4

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!

Tags:

nextjswebdevtutorialreact
1 Comment
Bayu Setiawan
Bayu Setiawan
Dec 05, 2023, 21:39

Hi, kindly leave a like and comment if you got new insight! 🔥