Questions? Ask in Slack #vcc-ui
@volvo-cars/react-utils
This package exposes useful generic hooks that don't belong to a hook collection (like react-layout-utils
)
$ yarn add @volvo-cars/react-utils
💡 This package includes Typescript definitions
Returns the previous value of a passed prop or state.
Name | Description | Type | Default Value |
---|---|---|---|
value | The property you wish to know the previous state of post re-render | unknown | undefined |
Adds an event listener on component mount that invokes the provided callback function on matching key(s)press.
useKeyPress('Escape', () => console.log('Escape key pressed!')
Name | Description | Type | Default Value |
---|---|---|---|
keysToListenTo | Comma or space delimited list of keys to listen to | string | undefined |
callback | Function to be invoked on keypress | func | undefined |