npm

npm’s 2019 JavaScript ecosystem survey analysis is now available! Get your copy here »

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

install

npm i focus-hook

Downloadsweekly downloads

3

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability