Package Exports
- @rocket.chat/fuselage-hooks
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rocket.chat/fuselage-hooks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Welcome to @rocket.chat/fuselage-hooks 👋
React Hooks for Fuselage, Rocket.Chat's design system
🏠 Homepage
Install
yarn add @rocket.chat/fuselage-hooksRun tests
yarn testAPI Reference
Table of Contents
- useClassName
- useDebouncedUpdates
- useDebouncedReducer
- useDebouncedState
- useDebouncedCallback
- useExclusiveBooleanProps
- useMediaQuery
- useMergedRefs
- useMutableCallback
- useToggle
useClassName
Hook to generate a BEM-compatible className value for a component.
Parameters
- componentClassNamestring the style class which identifies the component
- modifiersObject the modifiers applied to the style class (optional, default- {})
- classNames...Array<string> the additional style classes appended to the- className
Returns string a BEM-compatible className in the format
 (<block>|<block>__<element>) [...(<block>--<modifier>|<block>__<element>--<modifier>)] [...classNames]
useDebouncedUpdates
Hook to debounce the state updater function returned by hooks like useState() and useReducer().
Parameters
- pair[any, function (): any] the state and updater pair which will be debounced- pair.0the state value
- pair.1the state updater function
 
- delaynumber the number of milliseconds to delay the updater
Returns any a state value and debounced updater pair
useDebouncedReducer
Hook to create a reduced state with a debounced dispatch() function.
Parameters
- reducerfunction (any, any): any the reducer function
- initializerArgany the initial state value or the argument passed to the initial state generator function
- initializerfunction (any): any the initial state generator function
- delaynumber the number of milliseconds to delay the updater
Returns any a state and debounced dispatch() function
useDebouncedState
Hook to create a state with a debounced setter function.
Parameters
- initialValue(any | function (): any) the initial state value or the initial state generator function
- delaynumber the number of milliseconds to delay the updater
Returns any a state and debounced setter function
useDebouncedCallback
Hook to memoize a debounced version of a callback.
Parameters
- callbackfunction (): any the callback to debounce
- delaynumber the number of milliseconds to delay
- depsArray<any>? the hook dependencies
Returns function (): any a memoized and debounced callback
useExclusiveBooleanProps
Hook for asserting mutually exclusive boolean props. Useful for components that use boolean props to choose styling variants.
Parameters
- propsObject the mutually exclusive boolean props
- Throws any if two or more booleans props are set as true 
useMediaQuery
Hook to listen to a media query.
Parameters
- querystring the CSS3 media query expression
Returns boolean true if the media query matches; false is it does not match or the query is not defined
useMergedRefs
Hook to merge refs and callbacks refs into a single callback ref. Useful when your component need a internal ref while receiving a forwared ref.
Parameters
- refs...Array<Ref<any>> the refs and callback refs that should be merged
Returns any a merged callback ref
useMutableCallback
Hook to create a stable callback from a mutable one.
Parameters
- fnfunction (): any the mutable callback
Returns any a stable callback
useToggle
Hook to create a toggleable boolean state.
Parameters
- initialValue(any | function (): any) the initial value or the initial state generator function
Returns any a state boolean value and a state toggler function
Author
👤 Rocket.Chat
- Twitter: @RocketChat
- Github: @RocketChat
🤝 Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Show your support
Give a ⭐️ if this project helped you!
This README was generated with ❤️ by readme-md-generator