-
Notifications
You must be signed in to change notification settings - Fork 2
/
react-bouncer.js.map
1 lines (1 loc) · 1.34 KB
/
react-bouncer.js.map
1
{"version":3,"file":"react-bouncer.js","names":["bouncer","Comp","duration","method","debounce","props","dep","forceUpdate","useReducer","x","updater","useCallback","useEffect","useMemo"],"sources":["src/react-bouncer.js"],"sourcesContent":["import {useEffect, useCallback, useMemo, useReducer} from 'react'\nimport debounce from 'lodash.debounce'\n\nconst bouncer = (Comp, duration = 300, method = debounce) => props => {\n // https://reactjs.org/docs/hooks-faq.html#is-there-something-like-forceupdate\n const [dep, forceUpdate] = useReducer(x => ++x, 0)\n const updater = useCallback(method(forceUpdate, duration), [])\n\n // call the delayed function when props change (or was re-rendered without any props)\n useEffect(updater, [props])\n\n return useMemo(() => <Comp {...props}/>, [dep])\n}\n\nexport default bouncer\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEA,MAAMA,OAAO,GAAG,UAACC,IAAD;EAAA,IAAOC,QAAP,uEAAkB,GAAlB;EAAA,IAAuBC,MAAvB,uEAAgCC,eAAhC;EAAA,OAA6CC,KAAK,IAAI;IAClE;IACA,MAAM,CAACC,GAAD,EAAMC,WAAN,IAAqB,IAAAC,iBAAA,EAAWC,CAAC,IAAI,EAAEA,CAAlB,EAAqB,CAArB,CAA3B;IACA,MAAMC,OAAO,GAAG,IAAAC,kBAAA,EAAYR,MAAM,CAACI,WAAD,EAAcL,QAAd,CAAlB,EAA2C,EAA3C,CAAhB,CAHkE,CAKlE;;IACA,IAAAU,gBAAA,EAAUF,OAAV,EAAmB,CAACL,KAAD,CAAnB;IAEA,OAAO,IAAAQ,cAAA,EAAQ,mBAAM,qBAAC,IAAD,OAAUR;IAAV,EAAd,EAAkC,CAACC,GAAD,CAAlC,CAAP;EACH,CATe;AAAA,CAAhB;;eAWeN,O"}