focus-hook

1.0.0 • Public • Published

focus-hook Build Status

Focus hook for virtual-dom

Install

$ npm install --save focus-hook

Usage

var h = require('virtual-dom/h')
var FocusHook = require('focus-hook')
 
function render (state) {
  return h('input', {
    focus: FocusHook(function () {
      return state.active
    })
  })
}

API

FocusHook([predicate]) -> object

predicate

Required
Type: function
Arguments: node

An optional predicate function. If provided, it will be called asynchronously with the inserted DOM node. If it returns a truthy value, the Node will be focused, otherwise the hook is a noop.

If a predicate is omitted, the element will always be focused.

License

MIT © Ben Drucker

Dependents (1)

Package Sidebar

Install

npm i focus-hook

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • bendrucker