Video není dostupné.
Omlouváme se.

You can't console.log in React

Sdílet
Vložit
  • čas přidán 30. 07. 2021
  • 📘New Course: Build full-stack React Typescript applications tsreact.maksimivanov.com/s/ytd
    Apparently, if you pass the console.log function to some event handler or other kind of prop in React it won't work. I mean it won't log anything.
    Why is it so? Let's find out!

Komentáře • 34

  • @rentabestfriend
    @rentabestfriend Před 2 lety +10

    The only place on youtube where Theon Greyjoy teaches you how to code.

  • @artefactory99
    @artefactory99 Před 3 lety +3

    Tried to do that once in React and it didn't work, i thought it's weird but didn't pay attention - now you made things clear

  • @johnpublic6623
    @johnpublic6623 Před 3 lety +7

    It's not console logging, but I am having very similar issue when I try to embed react-native-google-places-autocomplete in a sub-component. Simply nothing happens. No error, nothing. It's maddening. Put it in it's own screen and it's fine. Because of this, I'm going to trace and see if React is preventing it firing in a similar way. Thanks!

    • @brianmoyou1949
      @brianmoyou1949 Před 3 lety +1

      You always have to give the autocomplete component an explicit height and and width. Otherwise it won‘t render the list of places. Is there any chance I can see the source code?

  • @ajalasegun1
    @ajalasegun1 Před 3 lety +4

    I have been having an issue console logging in a RN app. I will give this a try. I hope it works

  • @MsZastra
    @MsZastra Před 3 lety

    What the orange pedal on top shelf?)

  • @rodrigoibarra1981
    @rodrigoibarra1981 Před 2 lety +1

    So, how can I log the event? I'm stuck on this :/

  • @avidrucker
    @avidrucker Před 2 lety

    To answer the question asked, I think it is supposed to be read "side-effect-free"... In other words, when there are no side-effects. My understanding is that components will not re-render unless something in a component changes, or something manually invokes a component lifecycle method.

  • @resurrexi
    @resurrexi Před 2 lety +2

    My interpretation of the comment about "free replaying on render function" means that the devs want to free the replaying of console logging when a component is re-render. Speaking of which, I just noticed you're the author of the book I'm currently reading and in the trello clone section, the text in the book says "Right now in our App.tsx we already pass console.log as the onAdd prop to the NewItemForm element. Launch the app and try pressing Enter after you enter some text into the list-adding input." When I tried pressing Enter or clicking the button, nothing logged to console. I added a console.log(onAdd) statement in the code and it spat out "f disabledLog()". I then wrote my own consoleLog function and that worked so I thought it was weird how passing my own function vs passing console.log as the callback made a difference. Who knew that googling "react console.log as callback" would lead me straight to your video lol. Anyways, I hope you fix the text in your book for future readers. Other than that, I'm loving the book so far.

    • @satansdeer1
      @satansdeer1  Před 2 lety +3

      Hi, there is a huge update coming soon where i'll fix this and a bunch of other issues 👍

    • @resurrexi
      @resurrexi Před 2 lety +1

      @@satansdeer1 Just want to report another error in the text. At the Trello clone project, where I'm instructed to install react-dnd, it says "react-dnd-html5-backend@4.0.0". I think it meant to say "14.0.0".

  • @siamakvakili49
    @siamakvakili49 Před 2 lety

    Great point! 👌

  • @mr.crab2024
    @mr.crab2024 Před 3 lety +1

    Thanks for video

  • @avidrucker
    @avidrucker Před 2 lety

    I'd love to see more videos highlighting React "gotchas"

  • @shlomoh.6148
    @shlomoh.6148 Před 2 lety +1

    .log is a method it doesn't do anything if you just run console.log

    • @satansdeer1
      @satansdeer1  Před 2 lety

      When you pass it as a handler it is supposed to be called with the arguments of that handler. In this case it should get event and log it. In recent React versions they removed the behaviour shown in this video, so if you do it now it will log the event

  • @ru-is-terrorist-state
    @ru-is-terrorist-state Před 3 lety +1

    Ахахахахах)))
    Действительно забавная механика)))
    Повеселил)

  • @baigeldysultanov
    @baigeldysultanov Před 6 měsíci +1

    Вери юсфул видео, сенк ю, спасио

  • @DIEZ919191
    @DIEZ919191 Před 3 lety

    Cool

  • @jerrygreenest
    @jerrygreenest Před 3 lety +1

    callCallCallCallCallback!

  • @krishanlanka7659
    @krishanlanka7659 Před 3 lety +1

    Dear sir can you explain this in javascript console error messsage "Page layout may be unexpected due to Quirks Mode"

  • @arazmammadov9276
    @arazmammadov9276 Před 3 lety +1

    Aliens are real

  • @cis84muz
    @cis84muz Před 3 lety +5

    This is why I hope React will pass away. It is cool in general, but such things are unnecessarily complicated. In for example Svelte, everything is much simpler: console.log is just console.log :)

    • @mrkhoros
      @mrkhoros Před 3 lety +3

      pass away? I got news flash for you. React is the most popular framework for JS and it is gonna be like this for a very long time. Get used to it. What a horrible comment.

    • @cis84muz
      @cis84muz Před 3 lety +2

      ​@@mrkhoros I know, I work in React for 5 years and I will probably next 5 years :) Before I use to work with PHP 10 years and I was saying the same: PHP is not good, it should pass away, and now it slowly pass.

    • @mrkhoros
      @mrkhoros Před 3 lety

      @@cis84muz I see your game. I worked in react for 15 years and worked in php for 19 years and worked in c for 87 years and therefore React should die. right? Are you high on crack or something?

    • @Andrey-il8rh
      @Andrey-il8rh Před 3 lety +3

      @@mrkhoros got news for you too - jQuery also was most popular lib once as well as Flash, and where are they now?

    • @mrkhoros
      @mrkhoros Před 3 lety +1

      @@Andrey-il8rh Jquery is still one of the most used and popular frameworks. 40 million websites use it as of today only in the US. Shame on your for spreading misinformation.