{"_id":"@autotelic/react-resolve-dependencies","_rev":"1-b5c0f72704f77388e4873e996f329786","name":"@autotelic/react-resolve-dependencies","dist-tags":{"latest":"0.2.1"},"versions":{"0.2.1":{"name":"@autotelic/react-resolve-dependencies","version":"0.2.1","description":"Resolve dependencies before rendering a React component","main":"lib/index.js","scripts":{"lint":"eslint src","build":"rimraf lib && babel src --out-dir lib","build:watch":"watch 'npm run build' ./src/","prepublish":"npm run build","test":"mocha --require @babel/register --recursive ./test --require ./test/setup.js"},"keywords":[],"author":{"name":"Edward Stone &lt;ed@autotelic.com&gt;"},"repository":{"type":"git","url":"git+https://github.com/autotelic/react-resolve-dependencies.git"},"bugs":{"url":"https://github.com/autotelic/react-resolve-dependencies/issues"},"homepage":"https://github.com/autotelic/react-resolve-dependencies","license":"MIT","dependencies":{"hoist-non-react-statics":"^3.3.0"},"devDependencies":{"@babel/cli":"^7.5.5","@babel/core":"^7.5.5","@babel/plugin-proposal-class-properties":"^7.5.5","@babel/preset-env":"^7.5.5","@babel/preset-react":"^7.0.0","@babel/register":"^7.5.5","babel-eslint":"^10.0.2","chai":"^4.2.0","enzyme":"^3.10.0","enzyme-adapter-react-16":"^1.14.0","eslint":"^6.1.0","eslint-plugin-mocha":"^6.0.0","eslint-plugin-react-hooks":"^1.6.1","jsdom":"^15.1.1","mocha":"^6.2.0","react":"^16.9.0","react-addons-test-utils":"^15.6.2","react-dom":"^16.9.0","rimraf":"^2.6.3","sinon":"^7.3.2","watch":"^1.0.2"},"peerDependencies":{"react":">=16.8.0","react-dom":">=16.8.0"},"npmName":"react-resolve-dependencies","npmFileMap":[{"basePath":"/lib/","files":["*.js"]}],"gitHead":"6971b8bbd0747e5c7722ab57a26abfa97aec9497","_id":"@autotelic/react-resolve-dependencies@0.2.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-oTgIAtM3Cei+OKshHMVT0YGDN6jr9IgG3Tp/G1lgf+EfLie/QlNUSeO/K9Z3t8K5Ee1M9Zoim38qqe+7WWYjyg==","shasum":"dc95311eef338ad79426a1bce42834e9957b0516","tarball":"https://registry.npmjs.org/@autotelic/react-resolve-dependencies/-/react-resolve-dependencies-0.2.1.tgz","fileCount":8,"unpackedSize":13265,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdi7GVCRA9TVsSAnZWagAAsqEP/015jfTKSMuMA0L7JLtl\n5k2VcZxm86ADc9CartHBoAihCMeFaXmUAj17tRp6nrZbdeELFoEjc5POmNC8\npBigXnOshjuSFqKeezPYibylBX5MPbgxQ+Vbxq8llvj7/mBkxVk186AJw4MJ\nLRbTJG43HhkrVeo2c4X9I26Ueu5R9xnDVqhJS0hV45QxGoaIhZGFrEFf7JC1\ntH4BhAnMHo/HVsk7D8cGxnE+cvQhZGo22Tv7zBo14zvf26F11J6n0dXB0Vlb\nktIRuD5HN46MVSICR+6LgXmSyIDGnswKr69u3wMMj3GgcnTaEWxffD1qZBjN\nj+5DV8HM7bAy9LHaQHcU2Ssx4NqkUvaAmbqC0b77YS9W8MkjVU5iMdlHNC5h\nCspuRpQVS/iYXPPHUOujAkgfVB8mja/OLVfoIIVpgoY0g6+haerTtnjfj6J2\nPy67FMu2zSx8xvCMfhMeoCBzUv8YRTweJ7WVg8FMoCNQvzrWR5salKc4JrPf\nP1qUzqW+iYyu4Lo7wIV4Cfv9ILXhotrgRoy4+hBWZf4HZtfjfpQu/1b1MImg\n1Z/3s0zIEvlRSsoW5a2NX9S5+8sCy+LDpECP1f2pnydbB0ddW4+KdJ+Jo7qb\nNErhLBE8dxvvDU6O6cMU7YmjvTdSr2kmkLDH6yDhKRWor4JN8nYsd47vSWRl\nGF9B\r\n=HybM\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGIdk1CF74Ars7ujfwVDZcU3QOEAwenLelPnOF7w8zL/AiEA9awVDFqv2bm16MfDGAh6o8qg8rSkKweXjP9zo9AVSKg="}]},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"_npmUser":{"name":"autotelic","email":"info+npm@autotelic.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/react-resolve-dependencies_0.2.1_1569436052197_0.9067208610664785"},"_hasShrinkwrap":false}},"time":{"created":"2019-09-25T18:27:31.978Z","0.2.1":"2019-09-25T18:27:32.798Z","modified":"2022-04-04T16:40:51.222Z"},"maintainers":[{"name":"autotelic","email":"info+npm@autotelic.com"}],"description":"Resolve dependencies before rendering a React component","homepage":"https://github.com/autotelic/react-resolve-dependencies","keywords":[],"repository":{"type":"git","url":"git+https://github.com/autotelic/react-resolve-dependencies.git"},"author":{"name":"Edward Stone &lt;ed@autotelic.com&gt;"},"bugs":{"url":"https://github.com/autotelic/react-resolve-dependencies/issues"},"license":"MIT","readme":"# react-resolve-dependencies\n\nA [higher order component](https://medium.com/@franleplant/react-higher-order-components-in-depth-cf9032ee6c3e#.4osqw2gnf) that enables specifying dependencies that should be met before the component is rendered.\n\n## Installation\n\n    $ npm install react-resolve-dependencies\n\n## Usage\n\n```javascript\nimport React from 'react'\nimport resolveDependencies from 'react-resolve-dependencies'\n\nfunction dependency() {\n  return Promise.resolve('dependency resolved')\n}\n\nfunction onDependencyResolution(results) {\n  console.log(results)\n}\n\nfunction onDependencyFailure(reason) {\n  console.log(reason)\n}\n\nclass LoadingComponent extends React.Component {\n\n  render() {\n    <div>loading...</div>\n  }\n\n}\n\nclass FailureComponent extends React.Component {\n\n  render() {\n    <div>failed...</div>\n  }\n\n}\n\nclass ComponentWithDependencies extends React.Component {\n\n  static dependencies = [\n    dependency\n  ]\n\n  static onDependencyResolution = onDependencyResolution\n\n  static onDependencyFailure = onDependencyFailure\n\n  render() {\n    <div>all dependencies have now been resolved!</div>\n  }\n\n}\n\nexport default resolveDependencies(LoadingComponent, FailureComponent)(ComponentWithDependencies)\n\n```\n\nA 'dependency' is any function that returns a promise. Specify these in an array as a component property `dependencies`. The promises returned by the dependency functions will be passed to `Promise.all` and resolved before rendering the component. Whilst this takes place, the `LoadingComponent` passed to `resolveDependencies` will be rendered, passed the same props as the wrapped component. If no loading component is passed, then `null` will be rendered.\n\nIf any of the promises fail, then the `FailureComponent` will be rendered, passed the same props as the wrapped component. If no failure component is passed, then `null` will be rendered.\n\nIt's also possible to specify methods to be called in the event of dependency resolution or failure. These should be specified as component properties `onDependencyResolution` and `onDependencyFailure`, and will be passed either the results from `Promise.all`, or the reason for the failure, respectively.\n","readmeFilename":"README.md"}