hooks-and-utils
v2.0.2
Published
- Some React custom hook and utility function # usage - import { useOnClickOutside } from 'hooks-and-utils' - import { checkEmail } from 'hooks-and-utils'
Downloads
2
Readme
- Some React custom hook and utility function
usage
import { useOnClickOutside } from 'hooks-and-utils'
import { checkEmail } from 'hooks-and-utils'
import { hooks } from 'hooks-and-utils'
...
hooks.useOnClickOutside(...)
...
- import { utils } from 'hooks-and-utils'
...
utils.checkEmail(...)
...
hooks
- useOnClickOutside
- useScrollEnd
- params:
- scrollEleRef: reference of element have scroll was created by useRef
- callback:
- callback call when scroll is end
- this
callback
need received afunction
as parameter, afunction
is used to call in the end of thecallback
function
- dependencies: list of dependencies of callback function
- dependenciesScroll: list of dependencies to check re create event listener scroll
- Ex:
useScrollEnd(scrollEleRef, async (finishWaitingPromise) => { const result = await dispatch(someAction()) finishWaitingPromise() }, [], [])
- params:
utils
- arrayBufferToBlob
- autoDownloadFromBlob
- blobToArrayBuffer
- checkEmail
- fileToBase64
- getClassName
- Ex:
getClassName("class-1", null, "class-3") // return "class-1 class-3"
- Ex:
- getDimensionImg
- Ex:
getDimensionImg(img) // return {width: 320, height: 480}
- Ex:
- getNumberByLen:
- Ex:
getNumberByLen(2) // return "0002"
getNumberByLen(2, 6) // return "000002"
getNumberByLen(2, 6, "*") // return "*****2"
- Ex:
- numWith1000sSeparator
- Ex:
numWith1000sSeparator(10000) // return "10,000"
numWith1000sSeparator(10000, ".") // return "10.000"
- Ex:
- roundFloatNumber
- Ex:
roundFloatNumber(2.452, 2) // return 2.45
roundFloatNumber(2.456, 2) // return 2.46
- Ex:
- strToStrNoAccent