Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/prmichaelsen/react-ux-hooks

Hooks to measure DOM rects during resize, track viewport size, & disable iOS auto-input zoom.
https://github.com/prmichaelsen/react-ux-hooks

Last synced: 5 days ago
JSON representation

Hooks to measure DOM rects during resize, track viewport size, & disable iOS auto-input zoom.

Awesome Lists containing this project

README

        

## react-ux-hooks

Hooks to measure DOM rects during resize, track viewport size, & disable iOS Safari auto-input zoom.

### API & Examples

Track component size on resize:

```tsx
// declaration
declare function useDimensions(deps: any[], trackWindowResize?: boolean): {
ref: null;
dimensions: null;
} | {
ref: (node: any) => void;
dimensions: DOMRect;
};

// usage
export const Component = () => {
const { ref, dimensions } = useDimensions([], true);
return (


Component Width: {dimensions.width}px

);
}
```

Track viewport size:

```tsx
// declaration
export declare function useViewportSize(): {
width: number;
height: number;
};

// usage
export const Component = () => {
const { width } = useViewportSize();
return (


Viewport Width: {width}px

);
}
```

Disable auto-input zoom:

```tsx
// declaration
declare const useDisableAutoInputZoom: (disable: boolean) => void;

// usage
export const Component = () => {
useDisableAutoInputZoom(false);
return (

);
}
```

## FAQ
### Why package these hooks together?

Why not?