@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

4

Version

2.0.8

License

none

Unpacked Size

272 kB

Total Files

67

Last publish

Collaborators

  • mfernanda-sosa
  • dev-javu
  • vviswa
  • netolm-wp
  • yeswapo
  • harmanwapo
  • lpadillac4s
  • rjaya
  • granadoslopez
  • cashack
  • courtneybeesch
  • joshhoegen
  • thiago_srpt
  • alefkow
  • michelle_mark
  • ysmilde
  • shrddhawashpost
  • hanj.washpost
  • karenwang
  • carsonology
  • yuyanlei
  • dbnapp
  • colemanc4
  • vpenney
  • stevethedev
  • dkao
  • elenalacey
  • zhoyoyo
  • dwuandjune
  • fransandi
  • ashendruk
  • michaeldomine
  • mark-a-wapo
  • lenacohen
  • chris93007
  • sabrinamochi
  • jorgemhc-dev
  • carlyn
  • dgreen19
  • josephjames
  • niko_kom
  • nicrocs
  • avalbuena
  • sotojl
  • haileyhaymond
  • lukaskeelwapo
  • timborisenko
  • bantupallik
  • kt-prry
  • jesse.post.washpo
  • threeteaspoons
  • emilycsabens
  • luciovilla
  • tam.steph
  • agillespie
  • ani512
  • vonoehsene
  • emmakumer
  • aggyjlee
  • lavanderoi
  • emily.eng
  • lmelgar
  • sadbumblebee
  • janicekchen
  • jamelhendricks
  • ryanpicou
  • crunchwrap78
  • welchk
  • val-l-hosler
  • nick.mourtoupalas
  • benjaki
  • battand
  • jon.rosado
  • jacknugent27
  • asamireissa
  • courth
  • mahig
  • jchaskell
  • lorenzog
  • ln-washpost
  • stericson
  • talpert022
  • gengel
  • tuckabelle
  • nauticaharvin
  • aadittambe
  • natalievineberg
  • krbrooks
  • katty-huertas
  • mariaalconadabrooks
  • juniorh28
  • atomictangerine
  • emlorraine
  • helmsc
  • tritico
  • pranavganore
  • danacasidy
  • terrywp
  • ksemanur8
  • dreyvitser
  • mvonesh
  • chelseaconrad
  • arnolda-wp
  • hermionewy
  • wp-aberg
  • sheamus-hei
  • haysstephanie
  • broadwaterne
  • andrevinc
  • kat-alo
  • daniellersaul
  • stevefuenteswp
  • rekha26
  • marcnahed
  • amiemunoz
  • chloelangston
  • martinezy
  • seanwapo
  • ducroquet
  • jakekara
  • jtotoole
  • mjperales
  • arturgalocha
  • ebgranger
  • ramyalamati
  • adamsrobw
  • luke.connors
  • wrneff
  • mcdoh
  • floresa
  • taliatrackim
  • lennybronner
  • bitsoglass
  • it_procurement
  • davidchaiwapo
  • maddoxnelson
  • juliebacon
  • 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
  • brianaa
  • dsantamarina
  • artmsilva
  • ashtol
  • sberhanu
  • jjalcantara
  • alyssa.fowers
  • joemfox
  • reubenfb
  • calcantara
  • adrianblanco
  • chiquiesteban
  • iuraizee
  • bdgross
  • ulmonica
  • bmferrill
  • dankeating
  • emamd
  • timmeko
  • kevinuhrmacher
  • shellytan
  • harrystevens
  • chrisrukan
  • allisonnmann
  • aaronsteckelberg
  • shruthagandla
  • braforda
  • hannahmahon
  • adityajain15
  • linorabolini
  • anthonyjpesce
  • 1313davidlee
  • kate.rabinowitz
  • fontc
  • cecepascual
  • vsingarayar
  • aramzs
  • ruxk
  • nader_heidari
  • thompsond3
  • tylerremmel
  • tmac0201
  • joemoore-post
  • ealvarez79
  • hdormido
  • sgpotts
  • yutaochen
  • nwalker_wp
  • apbest
  • briannaschroer
  • shikha-sub
  • naema
  • chloemeister
  • julia.ledur
  • solomonsscott
  • betchavarria
  • eewright
  • nickkirkpatrick
  • trann_wapo
  • tobefrankhj
  • tierneyl
  • essiekim
  • sergio.pecanha
  • meganwalter
  • alyssabartuch
  • alexisbarnes
  • dmoriarty6
  • mokhtar.ali
  • dpham5
  • klimenkovd
  • davisshaver
  • aaronbrezel
  • moodypaige.e
  • kastningj