Files
react/packages/react-events/docs/Focus.md
2019-04-26 08:11:40 +01:00

814 B

Focus

The Focus module responds to focus and blur events on its child. Focus events are dispatched for mouse, pen, touch, and keyboard pointer types.

Focus events do not propagate between Focus event responders.

// Example
const TextField = (props) => (
  <Focus
    onBlur={props.onBlur}
    onFocus={props.onFocus}
  >
    <textarea></textarea>
  </Focus>
);
// Types
type FocusEvent = {
  target: Element,
  type: 'blur' | 'focus' | 'focuschange'
}

disabled: boolean

Disables all Focus events.

onBlur: (e: FocusEvent) => void

Called when the element loses focus.

onFocus: (e: FocusEvent) => void

Called when the element gains focus.

onFocusChange: boolean => void

Called when the element changes hover state (i.e., after onBlur and onFocus).