React tutorial in Hindi #12 State with class component

preview_player
Показать описание
in this react js tutorial for beginners series we learn how to use state in a class component in react js. This video is made by anil Sidhu in the Hindi Language.
Playlist for complete React series in Hindi

State in Class Component
Make Class Component
What is state
Define state
Update state with a Button click
Interview Question
Рекомендации по теме
Комментарии
Автор

Thanks a lot sir, I have learned many things.

kirtisoni
Автор

No, we can't use useState in class-component because, useState is a Hook and Hooks are not implement in class-component.

fatemapatel
Автор

In React, state is not public, state is private to the component in which it is defined. This means that the state is not accessible or modifiable by other components directly.

subhendu
Автор

No, you cannot use the useState hook in class components in React. The useState hook is a feature of React functional components introduced with hooks in React 16.8.

mshahdevs
Автор

ur videos are ultimate keep up the good work thanks

nabilalakhani
Автор

React Class Components have built in State Object. You might have noticed that we used state earlier in the component constructor section. The state object is where you store property values that belongs to the component. When the state object changes, the component re-render.

ONLY call useState() hooks inside a functional component: Hooks are created for functional components and should only be used in functional components. They don't work in class components. If you need to use state in the class component, then use the state object.

khyzersaleem
Автор

Is state public or private? you said, its public then we should be able to use it outside of component. And also you said, state can not be used outside the component. These two statements conflicts each other.

I think state in react is private, not public. what do you think? Please reply here.

navjyotyadav
Автор

No, we can't use hooks inside the class component

nikhilgaming
Автор

Sir I have a small doubt regarding state, apne bola state public hai but google mai private show kr raha hai. So which one is correct, please clear it.
Anyone also can verify me about this doubt.

ricky_una_
Автор

Can we only define the state without giving any value or data?

saurabhmore
Автор

this.setState is onestep behind. tried with await in SetState but that also not working. what might be wrong.When I am testing api with postman .Getting proper result but at the time of SetState it is one step behind when I console warn after assigning state

prosinging
Автор

Hello sir i have been watching your this series but it seems to me difficult as I am a beginner.plz make a videos of react which will have small code snippets as an examples to understand it better..

sachindandge
Автор

if i am using 2 this.state in the constructor() like this
constructor()
{
super();
this.state={data:"Himanshu"}
this.state={number:1}
}

but i am not getting any output on the browser until i click the button


return (
<div className="App">
<h1>{this.state.data}</h1>
<h1>{this.state.number}</h1>
<button
</div>
);

Can you tell me why ?

himanshuchauhan
Автор

Sir apne bola he ke state public hote hy lekin chatgpt to private btaa rhee he ap ye confirm kar den...

WebDeveloper
Автор

Sir state private hoti h na usko as a argument use krte h hm log dusre components me

ZahidKhan-thpz
Автор

Bhai very gud yaar, thanks bade bhai
Bss insta pe msg ka reply kar diya karo, and video me 5-7 min leke css ko bhi re-render karke dikha diya karo bhai

apkaChotaBhai
Автор

states are public ?is it right?i think private is right

shubhamkurulekar
Автор

How to update state immediately using class component?
Because whenever I try to do setState, it doesn't update immediately.
We can use useEffect in functional components
But what about class components?
How can we do it?

sanketdeogade
Автор

Sir why we are not use function keyword in that case

test-ki
Автор

we can use it

example.

const [state, setState] = useState({
count: 0
});

console.log(state.count);

and update it like this
setState({ count: state.count + 1 });

syedateeq