No, we can't use useState in class-component because, useState is a Hook and Hooks are not implement in class-component.
@jawadullah46852 жыл бұрын
Right
@khyzersaleem7 ай бұрын
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.
@nabilalakhani41823 жыл бұрын
ur videos are ultimate keep up the good work thanks
@mshahdevs2 ай бұрын
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.
@subhendu21344 ай бұрын
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.
@harmankaur3359 Жыл бұрын
clearly explained!
@shoaib4x5332 жыл бұрын
Maza aagya sir 🔥🔥
@saurabhmore51643 жыл бұрын
Can we only define the state without giving any value or data?
@ZahiidKhan2623 жыл бұрын
Yes empty
@prosinging78532 жыл бұрын
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
@khyzersaleem7 ай бұрын
Use Arrow Function In OnClick Then Use this.setState
@Pragya_Empower_Studies2 ай бұрын
Thank you.............
@ricky_una_16 Жыл бұрын
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.
@mohitpipaliya2594 Жыл бұрын
In React, state can be either public or private. Public State: Public state refers to the state that is accessible and modifiable from outside the component. It's typically used when the state needs to be shared across multiple components or when you want to update the state from a parent component. Public state is managed using the props system, where a parent component passes down state as props to its child components. This makes the state public and accessible to those child components. Private State: Private state refers to the state that is local and specific to a component. It's not directly accessible or modifiable from outside the component. Private state is managed using the useState or other state management tools within the component. It's used when you want to keep the state isolated to a specific component and avoid unintended interactions with other components. let me know if you still don't understand, I'll give you code example for better understanding
@fea25akshaygirase79 Жыл бұрын
op lecture sir
@navjyotyadav40539 ай бұрын
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.
@kevalhirpara67477 ай бұрын
bhai google me state private dikha rahi he
@DeepakGupta-hj2dv4 жыл бұрын
Redux ke video kab aayege?
@himanshuchauhan65203 жыл бұрын
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 ( {this.state.data} {this.state.number} this.Inc()}>Surname ); Can you tell me why ?
@ChandanSingh-ww5hr2 жыл бұрын
@himanshuchauhan6520 bro you don't need to create a separate state just put all the state data together like this super(); this.state={data:"Himanshusu", number:1} this will work
@ashurajput357 Жыл бұрын
@@ChandanSingh-ww5hr yes because mentioning this.state two times is wrong because now they are now different objects.
@ZahiidKhan2623 жыл бұрын
Sir state private hoti h na usko as a argument use krte h hm log dusre components me
@tejasdeore83402 жыл бұрын
No state public hoti h previous video me bataya h
@apkaChotaBhai3 жыл бұрын
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
@sachindandge7642 жыл бұрын
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..
@frontendwale2 жыл бұрын
Hi Sachin, you may try to look on this kzbin.info/door/jL4SPbBlJoOKT_YZz6zISQ
@tanmayhedau53422 жыл бұрын
u should have basic knowledge of html n css that's it and javascript too
@harshitrathi30774 жыл бұрын
Thankyou Bro
@codestepbystep4 жыл бұрын
welcome
@shubhamkurulekar45513 жыл бұрын
states are public ?is it right?i think private is right
@tejasdeore83402 жыл бұрын
He mentioned in his previous video that state is public
@nileshgore47902 жыл бұрын
yes bro I also think state is private
@WebDeveloper8319 ай бұрын
Sir apne bola he ke state public hote hy lekin chatgpt to private btaa rhee he ap ye confirm kar den...
@nikhilgaming41472 жыл бұрын
No,we can't use hooks inside the class component
@test-k5i3 жыл бұрын
Sir why we are not use function keyword in that case
@roshanpandey4041 Жыл бұрын
how state is public ?
@Ayush37262 Жыл бұрын
State is private
@sanketdeogade44902 жыл бұрын
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?
@aashitkumarsinha34592 жыл бұрын
use componentDidMount life cycle
@sanketdeogade2 жыл бұрын
@@aashitkumarsinha3459 How to make it work for last update of setState?
@aashitkumarsinha34592 жыл бұрын
@@sanketdeogade it get automatically render at time of states get loaded first time, but it also get called by React...when the state gets changes...
@abhisheksinghtomar1593 жыл бұрын
Why we can't use this.apple here?
@shaheenkhan63134 жыл бұрын
I think no we cannot use useState in class component because it gives error
@codestepbystep4 жыл бұрын
Right
@ayaankh2453 жыл бұрын
because it is hook. Hooks are for function components only.
@syedateeq16023 жыл бұрын
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 });
@riteshgoswami15963 жыл бұрын
hook in only for function component
@riderzzone6373 Жыл бұрын
laptop me charge bhi diya karo sir 🤣🤣
@codestepbystep Жыл бұрын
Haha
@GautamKumar_39 Жыл бұрын
STATE IS PRIVATE, NOT PUBLIC
@JavedAli-n7p7r8 ай бұрын
itna bareek kar rakha text dikh bhi ni raha
@anupriya4113 Жыл бұрын
state is private not public
@coder-cc4pd9 ай бұрын
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