#28: Why the state value does not reset to its initial value on re-render? Know the Real Reason🔥

Поделиться
HTML-код
  • Опубликовано: 5 окт 2024

Комментарии • 44

  • @ThapaTechnical
    @ThapaTechnical  3 месяца назад +1

    👉 Source code & PPT access Free: github.com/thapatechnical/react-19-series-thapa-technical
    👉 Here is the Complete Playlist: ruclips.net/p/PLwGdqUZWnOp1Rab71vx2zMF6qpwGDB2Z1

  • @verifiedbelieber719
    @verifiedbelieber719 3 месяца назад +1

    Watched a lot of react tutorials on youtube but noone ever explained this point. Thapa is expaining each snd evry details. This video deserves the caption world best react series.

  • @sanjibchanda21
    @sanjibchanda21 3 месяца назад +1

    Most effective sir

  • @vivekbhati9192
    @vivekbhati9192 3 месяца назад

    Nice video and In short -
    React does not call useState while updating the state.
    UseState get called only on mounting not on updating.
    For update life cycle we have setState.

  • @informativechannel2928
    @informativechannel2928 3 месяца назад +1

    Big Fan sir...
    Kindly
    material UI or react dono peh project banayein

  • @Fnydo
    @Fnydo 3 месяца назад +1

    Nice explanation ❤

  • @vidhipatel4022
    @vidhipatel4022 2 месяца назад

    thank you for this video it's helps me a lot

  • @iamMZ255
    @iamMZ255 3 месяца назад +1

    Awesome

  • @HamzaKhanLodhi-t6z
    @HamzaKhanLodhi-t6z 2 месяца назад

    Good Series.👍👍

  • @Vardanaggarwal
    @Vardanaggarwal 4 дня назад

    amazing sir.

  • @devarshi_tiwari1106
    @devarshi_tiwari1106 13 дней назад

    Amazing video 👏🏻

  • @aimalkhan4518
    @aimalkhan4518 3 месяца назад

    Thanks Sir👍

  • @pxycknomdictator4483
    @pxycknomdictator4483 3 месяца назад

    Thanks

  • @anwarulhaq1556
    @anwarulhaq1556 2 месяца назад

    amazing sir

  • @GraphOworld.00
    @GraphOworld.00 Месяц назад

    Bhaiya node js ka bhi bnaya sath sath me

  • @knowledgeera4492
    @knowledgeera4492 3 месяца назад

    bhai sare hook ka funda clear karouge kya ?

  • @prasadbagul2146
    @prasadbagul2146 3 месяца назад +1

    Sir Redux Thunk Full Course In Hindi Please

  • @immediateff
    @immediateff 29 дней назад

    the reason the value is not resetting on each render is that you're using React's useState hook, which preserves state across renders. This behavior is by design, as React hooks maintain state between renders, ensuring that when the component re-renders (for instance, after a state update), the value does not reset to its initial value.
    Here's a simplified breakdown of what's happening:
    🚀Initial render: value is 0 (the initial state).
    🚀You click the button, triggering setValue(value + 1).
    🚀React re-renders the component but remembers that value was updated to 1 (or the next value), so it uses this new value.
    🚀This process continues for every click, maintaining the updated state across renders.
    🚀That's why your value is not resetting to 0 upon re-renders.

  • @ajaydalal199
    @ajaydalal199 3 месяца назад

    Nice video bro

  • @aditya-d-
    @aditya-d- 3 месяца назад +1

    aysa saval hamne khabhi nahi saocha

    • @AmanKumarSinhaOfficial
      @AmanKumarSinhaOfficial 3 месяца назад

      😅

    • @xyonxyt9170
      @xyonxyt9170 3 месяца назад +1

      vai actually ham jo react documentation se sikhe he udhar aisey hi sikhaya gaya hai ki first click pe state change hota hai 0 to 1 then initial change ho gya aur is time pe prir se click karnese previous bala hi inertial count hua hai aur oske badh 1+1 = 2 ho jata hai

    • @aditya-d-
      @aditya-d- 3 месяца назад

      @@xyonxyt9170 actual truth

  • @SupriyoGhorui-j3d
    @SupriyoGhorui-j3d Месяц назад

    awesome

  • @ajiteshmishra0005
    @ajiteshmishra0005 3 месяца назад

    How are you using components in console window???
    Can you tell us what command we have to use to check as you are checking UI.

    • @vikrambais5330
      @vikrambais5330 2 месяца назад

      install react dev tool extention.. u can see the component structure in console

  • @weblogiclabs
    @weblogiclabs 3 месяца назад +2

    Bro is this react is full course for beginners ????

    • @skgamer2.027
      @skgamer2.027 3 месяца назад +2

      yes

    • @AmanKumarSinhaOfficial
      @AmanKumarSinhaOfficial 3 месяца назад +1

      100%

    • @weblogiclabs
      @weblogiclabs 3 месяца назад

      npm error }
      npm error
      npm error The operation was rejected by your operating system.
      npm error It's possible that the file was already in use (by a text editor or antivirus),
      npm error or that you lack permissions to access it.
      npm error
      npm error If you believe this might be a permissions issue, please double-check the
      npm error permissions of the file and its containing directories, or try running
      I got this error after installing bun

    • @AmanKumarSinhaOfficial
      @AmanKumarSinhaOfficial 3 месяца назад +1

      Chat GPT se solve krwa lo

    • @AmanKumarSinhaOfficial
      @AmanKumarSinhaOfficial 3 месяца назад +1

      Npm hi use kro.. Bun nhi

  • @karanxdev
    @karanxdev 3 месяца назад

    Its much harder to understand this in functional components as they see that there is a line of code written then why doesn't it affects ? Actually the best way to show this could be using class components or via a diagram that how it works. There is one more way (just for understanding) that the hook name is useState not createState (even though hook names always start with 'use') but still with it you can imagine. Someone could imagine useState means I want to use a state, If this state already exists, give me its value or create it with the initial value I passed in.

    • @karanxdev
      @karanxdev 3 месяца назад +2

      Even though video is good, still I would like to mention a point. He said the initial value is used only for the first time and he is right upto some extent but not always true. If the component is removed from tree, its state is deleted as well. So when it again is added to tree, it will use the initial value. You could create an example using a simple switch/checkbox which will ONLY render the counter component when its checked i.e render conditionally. I am NOT saying about hiding and showing the component using styling, but actually rendering conditionally

  • @SANSKARKISHAN
    @SANSKARKISHAN 2 месяца назад

    How to get Components in my Inspect as shown at 0:50

  • @hamudxd9497
    @hamudxd9497 3 месяца назад

    GOOD JOB❤

  • @Govind_thakur99
    @Govind_thakur99 3 месяца назад

    Nice sir ❤

  • @knowledgeera4492
    @knowledgeera4492 3 месяца назад

    bhai sabhi hook shikha na please mai apke sath start se hu

  • @AjazYaqub
    @AjazYaqub 3 месяца назад

    Ek minute Mai bhi btaya ja shkta tha video timing short krden but aise videos boring ja rhi hai video short krden or topic zada 30 minutes max ki toh bnayen lzmi

  • @Robennhood
    @Robennhood 3 месяца назад

    Api base project

  • @GauravSingh-id2mf
    @GauravSingh-id2mf 2 месяца назад

    thanks