React useState Hook | Learn ReactJS

Поділитися
Вставка
  • Опубліковано 24 гру 2024

КОМЕНТАРІ •

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  3 роки тому +8

    Learning the React useState hook is your first step towards learning about and managing state in React. Working with state requires you to think in a React-ful way which is different than Vanilla JS. That said, you should be familiar with Vanilla Javascript before learning the differences provided by React. If you are new to Javascript, I suggest beginning with my 8 hour full Javascript tutorial here: ua-cam.com/video/EfAl9bwzVZk/v-deo.html

  • @toonice555
    @toonice555 Рік тому +1

    Been using react for a while now and going through these videos really helped me understand certain things on a deeper level!

  • @BrainNotUsed
    @BrainNotUsed 3 роки тому +6

    Cannot wait to catch up! I have yet to start your React series as till now I was progressing my Vanilla JavaScript knowledge.
    You are an amazing tutor!

  • @yardleyfrausto7612
    @yardleyfrausto7612 3 місяці тому

    Im learning react now and I am so glad I came across this channell

  • @Sean-hd1bp
    @Sean-hd1bp 3 роки тому +3

    This is the best explanation of useState I could find. Nice one!

  • @zakariachajia1199
    @zakariachajia1199 7 місяців тому

    amazing video learned things in a new way still eager to finish this laylist

  • @quasi_verum
    @quasi_verum Рік тому

    4 years ago, I have really struggle to understand state concept. apart from class component concept, there aren't many creators who make content like you, Dave. It took me 2 week to figure out all about this.state, this.setState()(and all form of state mutation, and callback parameter), this.handleEvent.bind(this). Haven't hit componentDidUpdate yet. Thank you dave, at least there are a lot people that not struggle to understand hook useState.

  • @jizzervirusreptikonski8756
    @jizzervirusreptikonski8756 2 роки тому +4

    I think that count part should have been explained with reloading the page

  • @daman823
    @daman823 Рік тому

    Tese tutorials are awesome !! Keep going 🎉

  • @pranjalruhela1103
    @pranjalruhela1103 6 місяців тому

    the handlickick logs 0 because of the asynchronous nature of the setstate function. THe thing is that the code on the next lines are batched and kept aside while the program keeps on going and on the rerender the new state reflects but by that time console has logged the old value.

  • @dror-krief
    @dror-krief 8 місяців тому

    Thank you, Dave

  • @ahmedalsayeh5837
    @ahmedalsayeh5837 Рік тому +1

    thankYOU

  • @amulsharma564
    @amulsharma564 4 місяці тому

    Was looking for some better tutorial for React, Came across this "The Best Tutorial For React".

  • @aman7555
    @aman7555 2 роки тому

    Excellent content as always!

  • @samiullahsheikh5015
    @samiullahsheikh5015 2 роки тому +3

    Can you please explain the difference between these two?
    setValue( value + 1)
    VS
    setValue((prevValue) => prevValue + 1)

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +4

      Yes, you want this video on that topic: ua-cam.com/video/yvTGXH7uybA/v-deo.html

  • @immortalaigs4203
    @immortalaigs4203 2 роки тому

    i ended this tutorial! everyday 2 lessons i am learning :).

  • @ruebenhales8558
    @ruebenhales8558 2 роки тому

    Great job explaining Dave thank you!

  • @mubirujamesbenjamin3440
    @mubirujamesbenjamin3440 Рік тому

    Thank you.
    You're the best

  • @faisalejaz3893
    @faisalejaz3893 Рік тому

    Dave you are great

  • @utkarshp1108
    @utkarshp1108 2 роки тому

    avoiding mistakes part is working in my computer I've got 1 and after that added one more count+1 I've got 2

  • @harag9
    @harag9 Рік тому

    The gotcha for the adding of +1 and +1 to the count I can see getting loads of people. me included, it just doesn't make sense when you are reading line by line. IF you wanted to use the NEW updated count after adding the +1 to it at line 14, how do you do that? Can you do that? Would have been nice if you answered that question. Though it's good to know about the gotcha.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Рік тому

      I think this deeper dive will help answer your question: ua-cam.com/video/yvTGXH7uybA/v-deo.html

    • @harag9
      @harag9 Рік тому

      @@DaveGrayTeachesCode Thanks for the link to the video. I'll check it out.

  • @skillkrio
    @skillkrio 2 роки тому

    I didn't got any job so far. If i got any my first job is to support you .

  • @CAPS_AMERICA
    @CAPS_AMERICA Рік тому

    I got lost in setCount(count + 1). If count variable is a constant and setCount is the setter, isn't the same as passing setCount(0+ 1) which would set getter variable to 1 (count), the console.log(count) will be 1? Not sure I'm getting the logic here. You're calling setCount function first, console.log function comes next, why would the state of count unchanged when you've already set it to count + 1? Is there some kind of lazy loading where variable values are loaded even BEFORE calling a function in React?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Рік тому

      Good questions and the answer has to do with rendering and batch updates. Explained in greater detail here: ua-cam.com/video/yvTGXH7uybA/v-deo.html

  • @jamshidtashkent1976
    @jamshidtashkent1976 2 роки тому

    Really helped

  • @aya2222
    @aya2222 2 роки тому

    In handleClick function, the update of 'count' is asynchronous. That's why console.log(count) doesn't display updated 'count'. Is it right explanation?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому +1

      React does batch updates of state. The state variable retains the same value from when the component loads each time. Instead you must use a function in setState to pull in the previous state. It's a bit complicated to explain, but I provide another tutorial on it where the examples should do so nicely here: ua-cam.com/video/yvTGXH7uybA/v-deo.html

  • @ghostpieces2362
    @ghostpieces2362 3 роки тому

    Is this tutorial. When using setCount(count + 1), if you wanted to access the update count in the same function is that possible?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 роки тому

      Good question! I explain the answer to this exact question in this follow up tutorial: ua-cam.com/video/yvTGXH7uybA/v-deo.html

  • @psyferinc.3573
    @psyferinc.3573 2 роки тому

    your awesome dude

  • @DawinderSinghGhanauri
    @DawinderSinghGhanauri 2 роки тому

    code download link ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 роки тому

      There is not one for this specific lesson, but all download links for this series are found here: github.com/gitdagray/react_resources

  • @smithasilviadsouza
    @smithasilviadsouza Рік тому

    count state is getting changed for me

  • @trieudien1990
    @trieudien1990 2 роки тому

    good

  • @TravinskiyVladislav
    @TravinskiyVladislav 2 роки тому

    Top