Things you didn't know about re-rendering in React

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

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

  • @as_if
    @as_if 8 месяцев назад +15

    3 reasons re rendering happens
    - change of state value
    - change of props value
    - re rendering of parent/grandparent components (for the impurity (side effect) of a component)
    Rendering itself is a well optimised method thanks to reconciliation. Moreover-
    3rd reason can be avoided by using exporting default React.memo(component);

    • @KeshariPiyush24
      @KeshariPiyush24 5 часов назад

      Also in case of class components we can extend React.PureComponent instead of React.Component to make our class component PURE.

  • @ziaahmad8738
    @ziaahmad8738 Год назад +2

    Nice video. I see you linked Josh Comeau's article. I have also subscribed to his newsletter. Good stuff.

  • @razakadegoke3340
    @razakadegoke3340 9 месяцев назад

    Very well explained thx for your video

  • @as_if
    @as_if 8 месяцев назад

    Thank you sir

  • @PrajaktaBhapkar-v8i
    @PrajaktaBhapkar-v8i Год назад

    great explanation,alldoubts are clear,Thanks

  • @Monishreddy-l2k
    @Monishreddy-l2k 4 месяца назад

    Amazinggg explanation man

  • @amys6175
    @amys6175 Год назад

    This is very useful, thank you so much

  • @QuantumVoid-ro3hi
    @QuantumVoid-ro3hi 9 месяцев назад +1

    So what's the bottom line? That any component that doesn't depend on state OUTSIDE itself (apart from what's passed in through its props) is a candidate to be memeoized (including components that have internal state)?

  • @georgeem9954
    @georgeem9954 Год назад

    Excellent Explaination

  • @saifullahkhan3776
    @saifullahkhan3776 Год назад

    What an explanation!!!!! By the way you speak English so fluently

    • @CodeSketched
      @CodeSketched  Год назад +1

      Thanks a lot. Please check out the latest video. You will like that one too.

  • @nikhilfromyoutube
    @nikhilfromyoutube Год назад +1

    Good Explanation! I would like to you many video like this further.. ; )

  • @croccante7676
    @croccante7676 Год назад

    great explanation, thank you very much

  • @dailyPractice1
    @dailyPractice1 Месяц назад

    In my today's interview, Interviewer gave me same scenario question and asked if child component will re-render or not.

  • @aayushxhhetri1344
    @aayushxhhetri1344 5 месяцев назад

    lets say i have a const currentTime = new Date() below the count state and i try to render it Current Time: {currentTime.toLocaleTimeString()} in place of testcomponent ... then when i click the increament button the date also updates and shows the current date and time at the moment the button is clicked ..now you said that it wont happen because of virtual dom and it only renders the elements that is being updated but here this is no the case.. Can you explain why???

    • @Someguy-vl7dj
      @Someguy-vl7dj 5 месяцев назад

      He said it won't happen because if the virtual dom doesn't change, it doesn't send any change to the dom, but in your case, the virtual dom changed because "currentTime.toLocaleTimeString()" returned a different value.

  • @astronautischilling
    @astronautischilling Год назад

    ok + 1 subscribe, great explanation

    • @CodeSketched
      @CodeSketched  Год назад

      Thanks a lot. Please share the video :)

  • @mohamedshahrul1750
    @mohamedshahrul1750 11 месяцев назад +1

    u should have wrapped the Testcomponent in the React.memo for the example . since it doesnt receive any props but rerendner under a parent component. why u did u spoilt the video at end..

  • @thuannguyenlehoa9711
    @thuannguyenlehoa9711 11 месяцев назад

    when state change, the component whose state will be flagged -> React will go down through the Component to find the component flagged and update the Component tree -> JSX convert React Element -> new VirtualDom -> new VirtualDom diff old Virtual DOM -> actual DOM, right? but when will the component be flagged? ( when call setter function)