An open API service indexing awesome lists of open source software.

https://github.com/nath-green/hooks

Collection of hooks
https://github.com/nath-green/hooks

Last synced: 3 months ago
JSON representation

Collection of hooks

Awesome Lists containing this project

README

        

# hooks

Collection of hooks

- [useFocus](#user-content-usefocus)
- [useFocusOnMount](#user-content-usefocusonmount)

## useFocus

Returns `ref` and `setFocus()` to be used on an element which will receive event based focus.

```js
import { useFocus } from '@nath-green/hooks';

const { ref, setFocus } = useFocus();

setFocus()}>Focus heading

Focus on me


```

### Use case

When a modal has opened and the focus should be set to the close button.

## useFocusOnMount

Returns a `ref` to be used on an element which will receive focus on mount.

```js
import { useFocusOnMount } from '@nath-green/hooks';

const focusRef = useFocusOnMount();

Focused
```

### Use case

When a modal has opened and the focus should be set to the close button.