[
  {
    "path": ".babelrc.js",
    "content": "module.exports = {\n  presets: [\n    [\n      '@babel/preset-env',\n      {\n        loose: true,\n        modules: false,\n      },\n    ],\n    '@babel/preset-typescript',\n  ],\n}\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\ndist\ntypes\n"
  },
  {
    "path": ".huskyrc",
    "content": "{\n  \"hooks\": {\n    \"pre-commit\": \"lint-staged\"\n  }\n}\n"
  },
  {
    "path": ".lintstagedrc",
    "content": "{\n  \"*.{js,ts,json,md}\": [\n    \"prettier --write\",\n    \"git add\"\n  ]\n}\n"
  },
  {
    "path": ".npmrc",
    "content": "package-lock=false\n"
  },
  {
    "path": ".prettierrc",
    "content": "{\n  \"semi\": false,\n  \"singleQuote\": true,\n  \"trailingComma\": \"all\"\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) Andarist\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# use-constant\n\nReact hook for creating a value exactly once. `useMemo` doesn't give this guarantee unfortunately - https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily\n\n### Usage\nInstall the package\n```bash\nnpm install use-constant\n# OR\nyarn add use-constant\n```\n\nIn your code\n```javascript\nimport useConstant from 'use-constant';\n\nconst MyComponent = () => {\n  // Give useConstant() a function which should be be executed exactly once and\n  // return in it your constant value\n  const myConstantValue = useConstant(() => 42);\n  // ...\n```\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"use-constant\",\n  \"version\": \"2.0.0\",\n  \"description\": \"React hook for creating a value exactly once.\",\n  \"main\": \"dist/use-constant.cjs.js\",\n  \"module\": \"dist/use-constant.esm.js\",\n  \"exports\": {\n    \".\": {\n      \"types\": {\n        \"import\": \"./dist/use-constant.cjs.mjs\",\n        \"default\": \"./dist/use-constant.cjs.js\"\n      },\n      \"module\": \"./dist/use-constant.esm.js\",\n      \"import\": \"./dist/use-constant.cjs.mjs\",\n      \"default\": \"./dist/use-constant.cjs.js\"\n    },\n    \"./package.json\": \"./package.json\"\n  },\n  \"types\": \"./dist/use-constant.cjs.d.ts\",\n  \"files\": [\n    \"dist\",\n    \"types\"\n  ],\n  \"scripts\": {\n    \"test\": \"echo \\\"Warning: no test specified\\\" || jest --env=node\",\n    \"build\": \"preconstruct build\",\n    \"preversion\": \"npm test\",\n    \"prepare\": \"npm run build\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/Andarist/use-constant.git\"\n  },\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/Andarist/use-constant/issues\"\n  },\n  \"homepage\": \"https://github.com/Andarist/use-constant#readme\",\n  \"peerDependencies\": {\n    \"react\": \"^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0\"\n  },\n  \"devDependencies\": {\n    \"@babel/core\": \"^7.26.10\",\n    \"@babel/preset-env\": \"^7.26.9\",\n    \"@babel/preset-typescript\": \"^7.27.0\",\n    \"@preconstruct/cli\": \"^2.8.12\",\n    \"@types/react\": \"^16.8.8\",\n    \"fs-extra\": \"^7.0.1\",\n    \"husky\": \"^1.3.1\",\n    \"jest\": \"^24.5.0\",\n    \"lint-staged\": \"^8.1.5\",\n    \"prettier\": \"^1.16.4\",\n    \"react\": \"^16.8.4\",\n    \"typescript\": \"^5.8.3\"\n  },\n  \"preconstruct\": {\n    \"exports\": {\n      \"importConditionDefaultExport\": \"default\"\n    },\n    \"___experimentalFlags_WILL_CHANGE_IN_PATCH\": {\n      \"importsConditions\": true\n    }\n  }\n}\n"
  },
  {
    "path": "src/index.ts",
    "content": "import * as React from 'react'\n\ntype ResultBox<T> = { v: T }\n\nexport default function useConstant<T>(fn: () => T): T {\n  const ref = React.useRef<ResultBox<T>>()\n\n  if (!ref.current) {\n    ref.current = { v: fn() }\n  }\n\n  return ref.current.v\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"declaration\": true,\n    \"declarationDir\": \"./types\",\n    \"emitDeclarationOnly\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"lib\": [\"esnext\"],\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"resolveJsonModule\": true,\n    \"rootDir\": \"./src\",\n    \"skipLibCheck\": true,\n    \"strict\": true,\n    \"target\": \"esnext\"\n  }\n}\n"
  }
]