@washingtonpost/red-react-lib

2.0.8 • Public • Published

red-react-lib

This lib points to be a shared codebase for the different projects inside the WP.

For the time being we are using it as a git subtree

Updating this lib

In order to update/commit an update, the code needs to be built before pushing.

To build the project run

yarn install
yarn build

Modules

hooks

Functions

usePrevious(value)

usePrevious Hook

Got from https://usehooks.com/usePrevious/ It saves the previous value of props or state

usePromiseCallback(promise, deps, delayMS)

usePromiseCallback Hook

Hook dedicated to offer a sync way of accessing a promise state.

Keeps the last result until new results are loaded, to avoid UI flashes.

Supports a delayMS param to customise the loading threshold, to avoid UI flashes.

Only processes the last promise call.

usePromise(promise, deps, delayMS)

usePromise Hook

Wrapped usePromiseCallback.

It gets triggered on init and every time the args change by default.

Useful to fetch page data.

hooks

usePrevious(value)

usePrevious Hook

Got from https://usehooks.com/usePrevious/ It saves the previous value of props or state

Kind: global function

Param Type Description
value * The value to save

Example

const [state, setState] = React.useState()
const prev = usePrevious(state)

usePromiseCallback(promise, deps, delayMS)

usePromiseCallback Hook

Hook dedicated to offer a sync way of accessing a promise state.

Keeps the last result until new results are loaded, to avoid UI flashes.

Supports a delayMS param to customise the loading threshold, to avoid UI flashes.

Only processes the last promise call.

Kind: global function

Param Type Description
promise Promise The promise that would be wrapped
deps Array.<any> extra deps used to re-create the callback
delayMS number The delay in ms to switch the loading state to true

Example

const [callback, result, loading, err] = usePromiseCallback(Promise.resolve, [], 500)

usePromise(promise, deps, delayMS)

usePromise Hook

Wrapped usePromiseCallback.

It gets triggered on init and every time the args change by default.

Useful to fetch page data.

Kind: global function

Param Type Description
promise Promise The promise that would be wrapped
deps Array.<any> deps to call the function with
delayMS number The delay in ms to switch the loading state to true

Example

const [callback, result, loading, err] = usePromise(Promise.resolve, ["hello"], 500)

Readme

Keywords

none

Package Sidebar

Install

npm i @washingtonpost/red-react-lib

Weekly Downloads

12

Version

2.0.8

License

none

Unpacked Size

272 kB

Total Files

67

Last publish

Collaborators

  • luke.connors
  • wrneff
  • mcdoh
  • floresa
  • lavanderoi
  • taliatrackim
  • tomkaz-wapo
  • aggyjlee
  • emmakumer
  • vonoehsene
  • ani512
  • lennybronner
  • ln-washpost
  • jorgemhc-dev
  • bitsoglass
  • it_procurement
  • sabrinamochi
  • seanwapo
  • lorenzog
  • jchaskell
  • davidchaiwapo
  • agillespie
  • martinezy
  • tam.steph
  • colemanc4
  • luciovilla
  • ducroquet
  • threeteaspoons
  • maddoxnelson
  • stephanie.clark
  • jasonvuong
  • jkoo87
  • kankelcr
  • gregoryauld2014
  • uncompiled
  • jbrown4
  • scarothers
  • khan.salauddin
  • rowhawn
  • subs-npm-builder
  • nealhumphreywapo
  • ashlynstill
  • ptnielsen
  • leslie-s
  • courtney-kan
  • kevin.schaul
  • jakecrump
  • macallah
  • jmuyskens
  • madisonwalls
  • dsantamarina
  • artmsilva
  • ashtol
  • sberhanu
  • jjalcantara
  • alyssa.fowers
  • joemfox
  • reubenfb
  • calcantara
  • adrianblanco
  • chiquiesteban
  • iuraizee
  • bdgross
  • ulmonica
  • bmferrill
  • dankeating
  • timmeko
  • kevinuhrmacher
  • shellytan
  • harrystevens
  • chrisrukan
  • allisonnmann
  • aaronsteckelberg
  • carsonology
  • shruthagandla
  • braforda
  • fernandowz
  • adityajain15
  • linorabolini
  • anthonyjpesce
  • 1313davidlee
  • kate.rabinowitz
  • fontc
  • cecepascual
  • yuyanlei
  • vsingarayar
  • aramzs
  • ruxk
  • nader_heidari
  • thompsond3
  • tylerremmel
  • tmac0201
  • mahig
  • joemoore-post
  • ealvarez79
  • hdormido
  • sgpotts
  • yutaochen
  • nwalker_wp
  • apbest
  • briannaschroer
  • shikha-sub
  • naema
  • chloemeister
  • julia.ledur
  • solomonsscott
  • betchavarria
  • eewright
  • courth
  • nickkirkpatrick
  • trann_wapo
  • dbnapp
  • tobefrankhj
  • essiekim
  • sergio.pecanha
  • meganwalter
  • alyssabartuch
  • alexisbarnes
  • karenwang
  • dmoriarty6
  • mokhtar.ali
  • dpham5
  • klimenkovd
  • davisshaver
  • welchk
  • asamireissa
  • kastningj
  • pranavganore
  • terrywp
  • hermionewy
  • amiemunoz
  • sheamus-hei
  • nick.mourtoupalas
  • shrddhawashpost
  • wp-aberg
  • marcnahed
  • andrevinc
  • dreyvitser
  • val-l-hosler
  • stevefuenteswp
  • adamsrobw
  • jesse.post.washpo
  • ramyalamati
  • ebgranger
  • broadwaterne
  • rekha26
  • jacknugent27
  • ksemanur8
  • danacasidy
  • haysstephanie
  • benjaki
  • arturgalocha
  • jamelhendricks
  • kat-alo
  • mjperales
  • jtotoole
  • jakekara
  • jon.rosado
  • arnolda-wp
  • chelseaconrad
  • mvonesh
  • vithalanis
  • timborisenko
  • lukaskeelwapo
  • janicekchen
  • sadbumblebee
  • tritico
  • helmsc
  • atomictangerine
  • lmelgar
  • juniorh28
  • mariaalconadabrooks
  • katty-huertas
  • krbrooks
  • natalievineberg
  • aadittambe
  • nauticaharvin
  • tuckabelle
  • emily.eng
  • haileyhaymond
  • lpadillac4s
  • gengel
  • crunchwrap78
  • talpert022
  • stericson
  • harmanwapo
  • sotojl
  • josevazqueznpm
  • kt-prry
  • avalbuena
  • nicrocs
  • niko_kom
  • tab00
  • marcostarafwashpost
  • josephjames
  • dgreen19
  • carlyn
  • alvaror2w
  • karklisl
  • clau8a
  • jmiguelfloresg
  • vladimirjv
  • tawaddy
  • alvarovalino
  • alefkow
  • ysmilde
  • netolm-wp
  • allidinat
  • mark-a-wapo
  • flaviopsantannawapo
  • jondavenportwapo
  • michaeldomine
  • ashendruk
  • giomarwize
  • dev-javu
  • catherine1234
  • vviswa
  • cashack
  • dnparmar
  • gregmanifold
  • hannah.good
  • malocuevi
  • lmnaland
  • ericlau
  • mballenwp1
  • chen-josh
  • joshhoegen
  • hrecht
  • diegodisant
  • moodyp
  • fransandi
  • nikki.brimmer
  • dwuandjune
  • zhoyoyo
  • elenalacey
  • dkao
  • stevethedev
  • benjamin.djang
  • amayaverde
  • lindoj