Rendering a List of Components in React

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

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

  • @avertry9529
    @avertry9529 2 года назад +6

    Last week I found out why we shouldn't use the index as key.
    for example if index 0 is deleted, all the keys change their value as the index shifts(1 becomes 0, 2 becomes 1, etc.)
    Then ALL are re-rendered instead of just the updated or deleted one.
    The reason your code works without a key, is React will use the index itself, with a warning. I find it really useful to know why things work or don't work, and it helps in memorisation.

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

      May I know where you find this?

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

      @@shinobi1975 Cannot remember sorry.

  • @Pareshbpatel
    @Pareshbpatel Год назад +3

    So many key React concepts explained along the way. Thanks, Sam
    PS You have a great teaching style.
    {2023-06-07}

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

    You taught this concept in 8 mins that my teacher couldn't do in 90 mins. Cheers

  • @mrholmes1266
    @mrholmes1266 2 года назад +2

    Great videos mate learning alot from you!

  • @samsorge27
    @samsorge27 2 года назад

    Great Tutorial,so happy I found your channel

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

    Very nice thanks Sam

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

    You deserve more fame

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

    good video. i understand that there should be uniqueness to the elements in the json array, but it's not very clear to me why there isn't an error when you create the joke component dynamically, as it looks like it only accepts joke and rating as arguments. i'm guessing it's something in vanilla javascript with how a function accepts arguments, but it's not very intuitive.

  • @siavoshoon
    @siavoshoon 2 года назад

    Greate job, same as always👍

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

    great video

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

    Thanks!

  • @AravinthK-q9k
    @AravinthK-q9k Год назад

    what if i am render a table instead of the joke component for me its getting page unresponsive if i render 30 tables inside that different rows and columns

  • @Cooper_246
    @Cooper_246 10 месяцев назад

    How did you make the like button glow like that, when you said to press it? Never seen that before, cool.