How to conditionally render in React - Web Front-end Development | Lesson 46 (Free Coding Bootcamp)

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

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

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

    What did you learn this lesson?

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

    Video just popped up on my recommended and I decided to watch it. It was the best decision I made. I am going to watch this whole series from the beginning. I want to learn web development and find it hard to find resources since I am only 19 and don't have much money to spend on courses.

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

    Hey I went through a few videos to see if I could find anything and couldn't.
    @ 2:25 what is " style={{ width: "${likes}px" }} " doing?
    I assume it should essentially be width: 0px, but if I replace it with width: "0px" there's obviously no image and I cant see a difference with the style line commented out or not.

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

      Nice catch, I think that may have been a typo of some sort. You probably want to set a fixed value for the width or let the parent container control the sizing

  • @coindominoes8152
    @coindominoes8152 2 года назад +1

    In the last part, when you added the reveal button, why don't we use the else after the if? Is that because the Pokémon is displayed after the likes change to one as that would be the unconditional result? Then we don't need the else statement after if...

    • @CodewithVincent
      @CodewithVincent  2 года назад +1

      We don't need an else statement because in the if statement, we return a value. Return will exit the function immediately, so an else statement is not needed. Plus there are only 2 statements here so this is just a small optimization to write less code

    • @coindominoes8152
      @coindominoes8152 2 года назад +1

      @@CodewithVincent Ok I got it, so if we add more statements, we'll have to order each one by use of else if. Also an error is showing on my VS code which says that expected '===' instead of '==', but it isn't affecting the result, so why is the error showing

    • @CodewithVincent
      @CodewithVincent  2 года назад +1

      @@coindominoes8152 I believe I explained this in the intro to JavaScript video. Triple = is used to check value and type.
      I don't use JavaScript a lot and out of habit I use == instead.. But the right syntax should be ==. My bad 😭