The React Lifecycle: Simply Explained!

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 36

  • @edward-vonschondorf-dev
    @edward-vonschondorf-dev 8 วันที่ผ่านมา +9

    Definitely interested in more videos involving looking behind the scenes of how all these meta frameworks/libraries actually work. Does a great job of de-mystifying things.

  • @TYTAX_HOME_GYMS
    @TYTAX_HOME_GYMS 7 วันที่ผ่านมา +1

    Greetings from Poland. One of the best explanations of how React works that I have ever seen. I have been working with React and Next.js for two years and only now have I fully understood a few concepts of how React works. Thanks for this video.

  • @ayushdedhia25
    @ayushdedhia25 7 วันที่ผ่านมา +2

    Thank you for your videos. This one is very important video specially when you don't why your react code work unexpected because we don't know what actually happens BTS. This helps us to write better scalable code 🙏🏻

  • @AjithkumarSekar
    @AjithkumarSekar 7 วันที่ผ่านมา +1

    Wow.. what a timing. I was just looking for this 2 days ago and thought it would be nice if you have any videos on it

  • @germain1984
    @germain1984 8 วันที่ผ่านมา +1

    love these types of videos, would be great if you used this format to go thru other concepts

  • @andyfoote8117
    @andyfoote8117 6 วันที่ผ่านมา

    Great explanation. Useful to see the differences between the client/server implementation being explained.

  • @serdotsenko
    @serdotsenko 7 วันที่ผ่านมา

    I loved how you explained the core concepts! To make this even more useful, I suggest adding a practical example, like a coding demo, to show how these ideas are applied in the real world.

  • @a-short-dev
    @a-short-dev 8 วันที่ผ่านมา +1

    This is the best, I can now answer interview questions better

  • @farzadmf
    @farzadmf 7 วันที่ผ่านมา +1

    Very nice explanation; thank you!

  • @mohamedsalimbensalem6118
    @mohamedsalimbensalem6118 8 วันที่ผ่านมา +2

    Finally, the video that ive been waiting for,
    Thanks darius for the video ❤

  • @AlphaTechy
    @AlphaTechy 6 วันที่ผ่านมา

    Very nice explanation ❤ , Thanks

  • @yogeshk4348
    @yogeshk4348 8 วันที่ผ่านมา +1

    Love from INDIA ....

  • @fitsaleem
    @fitsaleem 4 วันที่ผ่านมา

    great cosden

  • @kartikvishwakarma7567
    @kartikvishwakarma7567 5 วันที่ผ่านมา

    Great explanation specially server components part. So what I get is every react lifecycle whether its mounting, updation, or unmounting it creates a new virtual dom and replaces the real dom with the nodes which are changed only, right?

  • @developertools95
    @developertools95 7 วันที่ผ่านมา +1

    u r my bosss

  • @ptolemyhenson6838
    @ptolemyhenson6838 7 วันที่ผ่านมา +1

    Does React run effect cleanup only after unmounting, or also before each rerun of the actual effect?

    • @cosdensolutions
      @cosdensolutions  7 วันที่ผ่านมา +2

      Both

    • @tonyg_nerd
      @tonyg_nerd 6 วันที่ผ่านมา +1

      @cosdensolutions Big thanks to you for this vid and all others. Please forgive a bit of fine-tuning:
      With a dependency array with elements, the cleanup function is executed before the effect re-runs due to a change in the dependencies.
      - Cleanup is not run if dependencies haven't changed.
      If the dependencies array is empty ([]), the effect runs only once when the component mounts, and the cleanup runs only once when the component unmounts.
      If no dependency array is provided, yes, the effect runs on every render, and the cleanup also runs before every re-run of the effect.
      If an async operation is performed in cleanup, It is not scheduled with priority before the effect. It's run synchronously, and any async handling will probably follow the effect processing.
      To summarize:
      - If the effect is going to run, cleanup will run before it.
      - If the effect is not going to run, cleanup will not run on re-render.
      - Cleanup always runs on unmount.
      - Avoid async in cleanup, or manage it carefully.
      I'm not being a smart-a** , these rules only became fully clear to me after watching this vid. Thanks!

  • @sjoerdvermeijden
    @sjoerdvermeijden 7 วันที่ผ่านมา

    So on every state change the VDOM is re-rendered?

  • @P.Shivakrishna
    @P.Shivakrishna 7 วันที่ผ่านมา +1

    what about useRef in updating stage how it is act in every state ?

    • @cosdensolutions
      @cosdensolutions  7 วันที่ผ่านมา +1

      it will update the value, but won't trigger a re-render. So the value will be updated in memory, but if you're using it in JSX, it won't be shown until something else triggers a re-render

  • @johnforeverrules
    @johnforeverrules 8 วันที่ผ่านมา +1

    first. nice video my man

  • @jamesbotwina8744
    @jamesbotwina8744 8 วันที่ผ่านมา +1

    Why isn't there an option to send you money through TH-cam? This is a great video. I'd give you $2.

    • @cosdensolutions
      @cosdensolutions  8 วันที่ผ่านมา +2

      appreciate the kind words!

  • @ali.thecoder
    @ali.thecoder 8 วันที่ผ่านมา +2

    Does this works in react native too ?

    • @cosdensolutions
      @cosdensolutions  8 วันที่ผ่านมา +4

      yeah, except the server part is still pending

  • @shahwaizkarim-h9z
    @shahwaizkarim-h9z 7 วันที่ผ่านมา

    sir let's take this example code : useEffect(() => {
    const connection = createConnection(serverUrl, roomId);
    connection.connect();
    return () => connection.disconnect();
    });
    As you said, when the component re-renders it runs the cleanup function at the end, and clean up function clears all the memory. If this happens then the connection should break due to a state change in component. Now this is pretty common we have to change states in every app. Would the connection break between two users if the cleanup function runs on state change in the above code?

    • @cosdensolutions
      @cosdensolutions  7 วันที่ผ่านมา

      it would, but you would pass `serverUrl` and `roomId` as dependencies to useEffect, so that useEffect will only run when the server url changes or the room id, which is what you want. Otherwise, the component can re-render all it wants, the useEffect won't re-run unless its deps change

    • @shahwaizkarim-h9z
      @shahwaizkarim-h9z 3 วันที่ผ่านมา

      @@cosdensolutions Thank you bro for the reply!

  • @SieanLeon
    @SieanLeon 8 วันที่ผ่านมา

    when the cleanup function is executed inside the useEffect() hook callback function? It’s kind of confusing the way useEffect() callback works. If this callback function is scheduled to be ran earlier why the its return only executed upon component unmount stage

    • @cosdensolutions
      @cosdensolutions  7 วันที่ผ่านมา +1

      check my useEffect tutorial video! it explains it super nicely

    • @SieanLeon
      @SieanLeon 7 วันที่ผ่านมา

      @ ok. 👌 Thanks! i’m just trying to refresh myself on latest React updates and implement later in my application UI. Some of these framework features had been forgotten already.

  • @PukarChhatkuli
    @PukarChhatkuli 2 วันที่ผ่านมา

    good

  • @rahulyo.gaming
    @rahulyo.gaming 16 ชั่วโมงที่ผ่านมา +1

    Sorry but actually it is a black board 😂

  • @quickindiarecipe
    @quickindiarecipe 6 วันที่ผ่านมา

    isn't useState also asynchronous?