1.0.10 • Published 9 months ago
react-basic-utils v1.0.10
react-basic-utils
A collection of basic utilities for react
useIsMobile
Returns true if the viewport width is smaller or equal than 1023px. A minimal required width can be passed in as an argument.
const isMobile = useIsMobile(); // useIsMobile(desiredMinWidth)useScroll
Get the scroll position within a HTMLElement or the window.
const scrollPositionX = useScroll(targetEl, SCROLL_DIRECTION.X);
const scrollPositionY = useScroll(targetEl, SCROLL_DIRECTION.Y);scrollTo
Scroll to the position of an HTMLElement.
scrollTo(targetEl);concatClassNames
Concatenate class names optionally.
const activateCssClass = true;
<div
className={concatClassNames([
"some-basic-class",
["optional-class", activateCssClass],
])}
/>;