# focus-hook

> Focus hook for virtual-dom

Latest version **1.0.0** (published 2015-09-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install focus-hook
pnpm add focus-hook
yarn add focus-hook
bun add focus-hook
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-09-04 |
| First published | 2015-09-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | virtual-dom, hook, focus, dom |

## Links

- npm: https://www.npmjs.com/package/focus-hook
- Repository: https://github.com/bendrucker/focus-hook
- Homepage: https://github.com/bendrucker/focus-hook#readme
- Issues: https://github.com/bendrucker/focus-hook/issues
- npm.io page: https://npm.io/package/focus-hook

## Dependencies (2)

- [next-tick](https://npm.io/package/next-tick.md) ~0.2.2
- [virtual-hook](https://npm.io/package/virtual-hook.md) ~1.0.1

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-09-04

## README

# focus-hook [![Build Status](https://travis-ci.org/bendrucker/focus-hook.svg?branch=master)](https://travis-ci.org/bendrucker/focus-hook)

> Focus hook for virtual-dom


## Install

```
$ npm install --save focus-hook
```


## Usage

```js
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](http://bendrucker.me)

---
_Source: https://npm.io/package/focus-hook · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
