React: Keyboard Event Handlers All 'Null'

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

    You can also extract the underlying (original) browser event from the Synthetic*Event wrapper via the nativeEvent property. E.g.,

    handleKeyDown: function(e) {
      console.log('keyDown:event', e.nativeEvent);
    },
    

    (Just as with @Riccardo's note about e.persist(), it's unclear how you're supposed to know this without reading the React.js source code.)

提交回复
热议问题