React: Keyboard Event Handlers All 'Null'

前端 未结 4 1682
南方客
南方客 2021-01-30 16:27

I\'m unable to get any of the React SyntheticKeyboardEvent handlers to register anything except null for the event properties.

I\'ve isolated t

4条回答
  •  被撕碎了的回忆
    2021-01-30 16:39

    As Riccardo Galli points out correctly, the log object is already garbage collected at the time you access it in the console.

    The solution I use is to just log a clone of the object, so it won't be garbage collected. Cloning can be done in a lot of ways, but since I use lodash, I log like this :

      handleKeyDown: function(e) {
          console.log(_.cloneDeep(e)));
        }
    

提交回复
热议问题