{"name":"react-promise-suspense","version":"0.2.1","description":"React hook for resolving promises with Suspense support","main":"build/index.js","repository":{"type":"git","url":"git+https://github.com/vigzmv/react-promise-suspense.git"},"keywords":["react","fetch","suspense","promise","hooks"],"author":{"name":"Vignesh M"},"license":"MIT","bugs":{"url":"https://github.com/vigzmv/react-promise-suspense/issues"},"homepage":"https://github.com/vigzmv/react-promise-suspense#readme","scripts":{"build":"tsc --outDir build","dev":"tsc --outDir build --watch","prepublishOnly":"npm run build","test":"exit 0"},"devDependencies":{"@types/node":"^10.12.1","typescript":"^3.1.5"},"dependencies":{"deep-equal":"^1.0.1"},"gitHead":"728a1b13cfb5e6c14cb625887a8dc61139ac0650","_id":"react-promise-suspense@0.2.1","_nodeVersion":"11.11.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-5qayzZQ1QxO7PnBauzqUNu1O36vs4d+Bp3HETG8EMIs6EJAbbzVGv+Uvg60ZAERg3DDApJuf3TPPimtux+p55Q==","shasum":"94d94c7352b3e2926b70cba3c841b7c7579b337a","tarball":"http://registry-npm.ywwl.com/react-promise-suspense/download/react-promise-suspense-0.2.1.tgz","fileCount":15,"unpackedSize":450996,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJchklcCRA9TVsSAnZWagAAu2MP/Rbu84PDiGGdnCeOml2x\n3JYAgfQ1Gmu/cmAEvVZA9j/Fcy2VoXxDxUktH+ldSiFujmWzgcLWCXG9gAyI\n0gKFj56gGnV4d1UCv9ujs0xizeAgT/JzYm9FmBG8rzt01P5N5aWAEK9jMO6z\n4PMPeQMpS70rFCnoe5L+DLVIFVde6Q369EFL7FesZn7iRtnolUXu3grdYolz\nGVkdxduEfDbfoyDsPThghL18wNz+lRY8RQq7tzByZnh+R5Xs58fMcUMEwqW8\nUAWoko/cikqsCwoiIP+E3xEggTr0X/y86JcQHQIIbGpm30KbY+WMHlos8cH/\nkh/y9peGVT1/eQH1Mqarj2L5PwPfGu9zF+GESUYQUWraMq4Hpt6kL3kYbUm+\n1mf1IOB20QNKE/JmjnoWEHj6D/cHY0AeK2Qzbu+tbRi8vkuiRK47LnajKABb\nWfsGdIxI3BuQGQUB6SP+wFnwK0Q3eIhb9pwP+cRL6ddEelDZn7xiibvN6DPZ\n/tEJUENjSsN3XrUREUSIiXJ2lMGXZcTSlmWb7kYjIviRfY7R5PeStM3C3xw5\nxDxWYRJtTpw3NSQklxo90ctjlWniIRvJJaq03JS43mBF4rVLGV8J+T7Kdx1c\nOsR9oHQMyAdjqbNeqGtZ5ejBtbVWAaFyKToy5ScaBkzapAnoQOMH5mGn8vQC\nMUwK\r\n=dv97\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBlqzRQwc1FzIs4HCN7h8WU/oEK6cYABw0vPX2UYT4DAAiAlA454uSXMk6rhDq3pRk2lzmOVz6eS8iDNchLLW8OUuQ=="}],"size":171184,"noattachment":false,"key":"/react-promise-suspense/-/react-promise-suspense-0.2.1.tgz"},"maintainers":[{"name":"vigzmv","email":"vigzmv@outlook.com"}],"_npmUser":{"name":"vigzmv","email":"vigzmv@outlook.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-promise-suspense_0.2.1_1552304476099_0.6599893873896936"},"_hasShrinkwrap":false,"readme":"# usePromise\n\nReact hook for resolving promises with Suspense support.\n\nInspired by [fetch-suspense](https://github.com/CharlesStover/fetch-suspense), but this one is not limited to fetch, `usePromise` works with any Promise.\n\n[![version](https://img.shields.io/npm/v/react-promise-suspense.svg)](https://www.npmjs.com/package/react-promise-suspense)\n[![minified size](https://img.shields.io/bundlephobia/min/react-promise-suspense.svg)](https://www.npmjs.com/package/react-promise-suspense)\n[![minzipped size](https://img.shields.io/bundlephobia/minzip/react-promise-suspense.svg)](https://www.npmjs.com/package/react-promise-suspense)\n[![downloads](https://img.shields.io/npm/dt/react-promise-suspense.svg)](https://www.npmjs.com/package/react-promise-suspense)\n\n## Install\n\n* `npm install react-promise-suspense --save`\n\n## Example\n\n- Here's an [Codesandbox example](https://codesandbox.io/s/react-promise-suspense-example-t14mh) of a setTimeout delayed component. \n\n- Awaiting a fetch promise:\n```js\nimport usePromise from 'react-promise-suspense';\n\nconst fetchJson = input => fetch(input).then(res => res.json());\n\nconst MyFetchingComponent = () => {\n  // usePromise(Promise, [inputs,],)\n  const data = usePromise(fetchJson, [\n    'https://pokeapi.co/api/v2/pokemon/ditto/',\n    { method: 'GET' },\n  ]);\n\n  return <pre>{JSON.stringify(data, null, 2)}</pre>;\n};\n\nconst App = () => {\n  return (\n    <Suspense fallback=\"Loading...\">\n      <MyFetchingComponent />\n    </Suspense>\n  );\n};\n```\n","publish_time":1552304476270,"_cnpm_publish_time":1552304476270,"dist-tags":{"latest":"0.3.4"}}