I Really Didn't Understand This..

Поділитися
Вставка
  • Опубліковано 24 січ 2025

КОМЕНТАРІ • 13

  • @coderyan
    @coderyan  2 місяці тому

    This article from the React docs might also help clear this up: react.dev/learn/reacting-to-input-with-state#how-declarative-ui-compares-to-imperative

  • @B0re_d
    @B0re_d 2 місяці тому

    Who on earth writes react the same way as imperative code

  • @random4561
    @random4561 2 місяці тому +3

    Little tip, when you update a state based on its previous value prefer using the function instead of what you're doing with the items list for example.
    Like :
    [someNumber, setNumber] = useState(0);
    setNumber((prev) => prev+1)
    This way you're sure to always have the ACTUAL previous value. :)

  • @TheHellishFrog
    @TheHellishFrog 2 місяці тому +2

    In imperative way you explicitly write the shortest possible code, that will just work, and you totally understand it. In "declarative" way you write the code you hope will work, using lots and lots of code that someone else wrote, and you, more often than not, don't really understand how it work.

    • @perigord6281
      @perigord6281 2 місяці тому

      I don't think that's how it works....

    • @TheHellishFrog
      @TheHellishFrog 2 місяці тому

      @perigord6281 How you think it does? By the miracle? Browsers understand only that f*cking vanilla js - nothing more.

    • @perigord6281
      @perigord6281 2 місяці тому

      @@TheHellishFrog not trying to be condescending but I have literally no idea what you're talking about

    • @TheHellishFrog
      @TheHellishFrog 2 місяці тому

      @perigord6281 Could I suggest - first get an idea based on solid understanding of the subject at hand - and only then - talk.

    • @perigord6281
      @perigord6281 2 місяці тому

      @@TheHellishFrog really just seems like you're placing declarative code as some sort of Boogeyman without any proper elaboration, but ok