React Utils

Questions? Ask in Slack #vcc-ui

@volvo-cars/react-utils

@volvo-cars/react-utils@volvo-cars/react-utils@volvo-cars/react-utils

This package exposes useful generic hooks that don't belong to a hook collection (like react-layout-utils)

Installation

$ yarn add @volvo-cars/react-utils

💡 This package includes Typescript definitions


usePrevious

Returns the previous value of a passed prop or state.

NameDescriptionTypeDefault Value
valueThe property you wish to know the previous state of post re-renderunknownundefined

useKeyPress

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!')
NameDescriptionTypeDefault Value
keysToListenToComma or space delimited list of keys to listen tostringundefined
callbackFunction to be invoked on keypressfuncundefined

2024 © Volvo Car Corporation