package.cjs.react-utils.useStateWithDependency.useStateWithDependency.js.map Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
{"version":3,"file":"useStateWithDependency.js","names":["_react","require","useStateWithDependency","defaultValue","dependencies","arguments","length","undefined","_useState","useState","_useState2","_slicedToArray2","value","setValue","useEffect","_default","exports"],"sources":["../../../../src/react-utils/useStateWithDependency/useStateWithDependency.js"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\nconst useStateWithDependency = (\n defaultValue,\n dependencies = [defaultValue]\n) => {\n const [value, setValue] = useState(defaultValue);\n\n useEffect(() => {\n setValue(defaultValue);\n }, dependencies);\n\n return [value, setValue];\n};\n\nexport default useStateWithDependency;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAMC,sBAAsB,GAAG,SAAzBA,sBAAsBA,CAC1BC,YAAY,EAET;EAAA,IADHC,YAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAACF,YAAY,CAAC;EAE7B,IAAAK,SAAA,GAA0B,IAAAC,eAAQ,EAACN,YAAY,CAAC;IAAAO,UAAA,OAAAC,eAAA,aAAAH,SAAA;IAAzCI,KAAK,GAAAF,UAAA;IAAEG,QAAQ,GAAAH,UAAA;EAEtB,IAAAI,gBAAS,EAAC,YAAM;IACdD,QAAQ,CAACV,YAAY,CAAC;EACxB,CAAC,EAAEC,YAAY,CAAC;EAEhB,OAAO,CAACQ,KAAK,EAAEC,QAAQ,CAAC;AAC1B,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,cAEad,sBAAsB","ignoreList":[]}