Installation

npm install reactlogic-hooks-library

API

The GIT repository is available on https://github.com/Hilver/reACTlogic

useCheckbox

Returns boolean value from checkbox input.

useInput

Returns provided value as string.

Playground

useRect(refEl?)

RefEl

Type: RefObject<HTMLElement>

A React ref element of which rect is counted. Properties describing the overall border-box in pixels. Properties other than width and height are relative to the top-left o the viewport. More info here.

Playground

useScroll({element?, debounce?, delayTime?, targetElement?})

element

Type: RefObject<HTMLElement>

Default: window

A React ref element of which scroll event will be measured.

debounce

Type: Boolean

If true then scroll event will use debounce function as delay, otherwise throttle function will be set. If this option is ommited, throttle is set as default.

delayTime

Type: number

Default: 0 ms

A number of milliseconds for delay function.

Playground

useSearch({data, search, type?, caseSensitive?})

data

Type: Array<string | number | object>

An array of data that will be filtered for a match.

Type: string | number

A string or number to be searched for.

type

Type: string<keyof data>

When input data is an array of objects, you have to specify which property include to search for. It should be string which is key of specified data objects.

caseSensitive

Type: boolean Default: true

An addition property which distinguish queries by case sensitive.

Playground

useSlider(indexLimit, changeSpeed?)

indexLimit

Type: number

A number of slides.

changeSpeed

Type: number

Default: 2000

A number of miliseconds between each slide change.

Playground