ReactJS Tutorial - 11 - SetState (English)

preview_player
Показать описание


Here's how setState is used in class components:

Updating State with an Object:
You can update the state by passing an object to setState. React will merge the new state object with the existing state, updating only the specified properties.
Updating State with a Function:
You can also use a function as an argument to setState, which receives the previous state as an argument and returns the new state object. This is useful when the new state depends on the previous state.
Using Callback with setState:
setState also accepts a callback function as the second argument, which is executed after the state has been updated and the component has been re-rendered. This can be useful for performing additional logic after state updates

#reactjs #react #javascript #coding #frontend #reactjstutorial #reactjsdeveloper #tutorial #tutorials #programming #reactjsprojects

0:00 Introduction
1:36 Counter Component & State
3:35 Update State
6:14 Set State
14:42 Overview
Рекомендации по теме