React Cookbook
上QQ阅读APP看书,第一时间看更新

There's more...

There are more events you can use in React:

Keyboard events:

  • onKeyDown is executed when a key is depressed
  • onKeyPress is executed after the key is released, but before onKeyUp is triggered
  • onKeyUp is executed last after the key is pressed

Focus events:

  • onFocus is executed when a control receives focus
  • onBlur is executed when a control loses focus

Forms events:

  • onChange is executed when the user changes the value in a form control
  • onSubmit is a particular prop for <form> that is called when a button is pressed, or when the user hits the return key within a field

Mouse events:

  • onClick is when the mouse button is pressed and released
  • onContextMenu is when the right button is pressed
  • onDoubleClick is when the user performs a double-click
  • onMouseDown is when the mouse button is depressed
  • onMouseEnter is when the mouse moves over an element or its children
  • onMouseLeave is when the mouse leaves an element
  • onMouseMove is when the mouse moves
  • onMouseOut is when the mouse moves off an element or over one of its children
  • onMouseOver is when the mouse moves over an element
  • onMouseUp is when a mouse button is released

Drag and drop events:

  • onDrag
  • onDragEnd
  • onDragEnter
  • onDragExit
  • onDragLeave
  • onDragOver
  • onDragStart
  • onDrop

For drag and drop, events I recommend using the react-dnd (https://github.com/react-dnd/react-dnd) library.