React: Keyboard Event Handlers All 'Null'

前端 未结 4 1718
南方客
南方客 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:53

    BinaryMuse provided the answer on IRC. Turns out it's just a quirk; you can't read the properties directly from SyntheticKeyboardEvent -- you need to specify the properties from the handler:

    handleKeyUp: function(e) {
     console.log(e.type, e.which, e.timeStamp);
    },
    

    http://jsfiddle.net/BinaryMuse/B98Ar/

提交回复
热议问题