package.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":["useState","useEffect","useStateWithDependency","defaultValue","dependencies","arguments","length","undefined","_useState","_useState2","_slicedToArray","value","setValue"],"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,SAASA,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAE3C,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,GAA0BR,QAAQ,CAACG,YAAY,CAAC;IAAAM,UAAA,GAAAC,cAAA,CAAAF,SAAA;IAAzCG,KAAK,GAAAF,UAAA;IAAEG,QAAQ,GAAAH,UAAA;EAEtBR,SAAS,CAAC,YAAM;IACdW,QAAQ,CAACT,YAAY,CAAC;EACxB,CAAC,EAAEC,YAAY,CAAC;EAEhB,OAAO,CAACO,KAAK,EAAEC,QAAQ,CAAC;AAC1B,CAAC;AAED,eAAeV,sBAAsB"}