Learn when SwiftUI re-renders views

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

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

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

    Great simple example, well done :)

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

    i have the similar problem where i have an array that conforms to a model, and it's being used in a lazyVgrid and a foreach loop. the issue is that when an array elemant get changed the whole foreach get redrawn. Can you help me solve that? or can you make a video about that.?

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

      I made a video about how to prevent SwiftUI from re-rendering views ruclips.net/video/TOmxDvCz7e4/видео.html is your issue similar to this one?

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

    recomputes body is more accurate way to say "re-renders"

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

    Simple and useful 👌
    Why the “let _ =“ before the print?

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

      Thanks!
      If you simply place print inside the view, it will complain that the body does not conform to the View protocol. However, when you assign it to a variable, it works. Since we are not using this variable, it can be ignored with an underscore.

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

      Ohhh, ok. Thanks for the explanation 🙏