PageSourceSearch

https://vcc-ui.vercel.app/_next/static/chunks/pages/docs/packages/react-utils-3b460d78f22882bf.js

js vcc-ui.vercel.app collected 2026-10-03 08:00:29 UTC 3,909 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9759],{20535:function(e,s,n){(window.__NEXT_P=window.__NEXT_P||[]).push(["/docs/packages/react-utils",function(){return n(401)}])},401:function(e,s,n){"use strict";n.r(s);var t=n(52322),c=n(45392);function i(e){let s=Object.assign({h1:"h1",p:"p",em:"em",a:"a",blockquote:"blockquote",code:"code",h2:"h2",hr:"hr",table:"table",thead:"thead",tr:"tr",th:"th",tbody:"tbody",td:"td",pre:"pre"},(0,c.ah)(),e.components),{Badgen:n,Install:i}=s;return n||r("Badgen",!0),i||r("Install",!0),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.h1,{id:"react-utils",children:"React Utils"}),"\n",(0,t.jsx)(s.p,{children:(0,t.jsxs)(s.em,{children:["Questions? Ask in ",(0,t.jsx)(s.a,{href:"https://vcc-consumer-digital.slack.com/archives/CCD2PPD0S",children:"Slack #vcc-ui"})]})}),"\n",(0,t.jsxs)(s.blockquote,{children:["\n",(0,t.jsx)(s.p,{children:"@volvo-cars/react-utils"}),"\n"]}),"\n",(0,t.jsx)(n,{name:"@volvo-cars/react-utils"}),"\n",(0,t.jsxs)(s.p,{children:["This package exposes useful generic hooks that don't belong to a hook collection (like ",(0,t.jsx)(s.code,{children:"react-layout-utils"}),")"]}),"\n",(0,t.jsx)(s.h2,{id:"installation",children:"Installation"}),"\n",(0,t.jsx)(i,{name:"@volvo-cars/react-utils"}),"\n",(0,t.jsxs)(s.blockquote,{children:["\n",(0,t.jsx)(s.p,{children:"\uD83D\uDCA1 This package includes Typescript definitions"}),"\n"]}),"\n",(0,t.jsx)(s.hr,{}),"\n",(0,t.jsx)(s.h2,{id:"useprevious",children:"usePrevious"}),"\n",(0,t.jsx)(s.p,{children:"Returns the previous value of a passed prop or state."}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Name"}),(0,t.jsx)(s.th,{children:"Description"}),(0,t.jsx)(s.th,{children:"Type"}),(0,t.jsx)(s.th,{children:"Default Value"})]})}),(0,t.jsx)(s.tbody,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"value"})}),(0,t.jsx)(s.td,{children:"The property you wish to know the previous state of post re-render"}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"unknown"})}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"undefined"})})]})})]}),"\n",(0,t.jsx)(s.h2,{id:"usekeypress",children:"useKeyPress"}),"\n",(0,t.jsx)(s.p,{children:"Adds an event listener on component mount that invokes the provided callback function on matching key(s)press."}),"\n",(0,t.jsx)(s.pre,{children:(0,t.jsx)(s.code,{className:"language-javascript",children:"useKeyPress('Escape', () => console.log('Escape key pressed!')\n"})}),"\n",(0,t.jsxs)(s.table,{children:[(0,t.jsx)(s.thead,{children:(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.th,{children:"Name"}),(0,t.jsx)(s.th,{children:"Description"}),(0,t.jsx)(s.th,{children:"Type"}),(0,t.jsx)(s.th,{children:"Default Value"})]})}),(0,t.jsxs)(s.tbody,{children:[(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"keysToListenTo"})}),(0,t.jsx)(s.td,{children:"Comma or space delimited list of keys to listen to"}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"string"})}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"undefined"})})]}),(0,t.jsxs)(s.tr,{children:[(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"callback"})}),(0,t.jsx)(s.td,{children:"Function to be invoked on keypress"}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"func"})}),(0,t.jsx)(s.td,{children:(0,t.jsx)(s.code,{children:"undefined"})})]})]})]}),"\n",(0,t.jsx)(s.hr,{})]})}function r(e,s){throw Error("Expected "+(s?"component":"object")+" `"+e+"` to be defined: you likely forgot to import, pass, or provide it.")}s.default=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{wrapper:s}=Object.assign({},(0,c.ah)(),e.components);return s?(0,t.jsx)(s,Object.assign({},e,{children:(0,t.jsx)(i,e)})):i(e)}}},function(e){e.O(0,[9774,2888,179],function(){return e(e.s=20535)}),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.