{"name":"staged-components","version":"1.1.3","scripts":{"build":"gulp prebuild && tsc","test":"jest"},"description":"Make React function component staged.","keywords":["react"],"main":"index.js","repository":{"type":"git","url":"git+https://github.com/awmleer/staged-components.git"},"author":{"name":"awmleer","email":"awmleer@icloud.com"},"license":"MIT","private":false,"devDependencies":{"@testing-library/jest-dom":"^4.0.0","@testing-library/react":"^8.0.1","@types/jest":"^24.0.15","@types/react":"^16.8.6","gulp":"^4.0.2","gulp-clean":"^0.4.0","jest":"^24.8.0","react":"^16.8.6","react-dom":"^16.8.6","ts-jest":"^24.0.2","typescript":"^3.5.2","use-debounce":"^2.1.0"},"peerDependencies":{"react":"^16.8.0 || ^17.0.0 || ^18.0.0"},"publishConfig":{"registry":"https://registry.npmjs.org"},"types":"./index.d.ts","gitHead":"6d5ba5bf924a511edfc4d4f206f0d58536cd0151","bugs":{"url":"https://github.com/awmleer/staged-components/issues"},"homepage":"https://github.com/awmleer/staged-components#readme","_id":"staged-components@1.1.3","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"integrity":"sha512-9EIswzDqjwlEu+ymkV09TTlJfzSbKgEnNteUnZSTxkpMgr5Wx2CzzA9WcMFWBNCldqVPsHVnRGGrApduq2Se5A==","shasum":"bb5a396df2d9b48fbc31841a59f53437ed8b8ac6","tarball":"http://registry-npm.ywwl.com/staged-components/download/staged-components-1.1.3.tgz","fileCount":5,"unpackedSize":4729,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHwLJM8jP+J1w0y3z8pKSzz3snR6aCnTMqkfDeFyE2ACAiAuezP1Y09SCm8MVX5ciAKnxxck4GvmLKdoLjO9/Ofvlg=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJikEXVACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpZLA//RpORKcGvl84hIaox7NSw7+S3HRwCNatJk9OJ+tG/WZg/4pS0\r\nGzbK8NDI+WZgmLquftxMam/cyJ5TY8o81p2bAhr29ygb/GWMBHjVC+52KB4W\r\nP37PP/W0f8AA0pQMTVu/J348/JLz2CBIz7UChPmIAaf8lAF4HxhKAQWISmG5\r\nmQQ80tpgfSHkYnKSQZ8m+2vilVi9XEACQxWJqXf7GMcJZkicz59ADkb3sJE4\r\n3rh49lVkaZFEL6T0Gfdqyi4mk7EYWgM42zaTrRoRwx8XT1BMQ/ZMOwM7y7ec\r\nyTZC/wAzLi6DkNZ7HoYKmT8gXvyPDfFNhhfVOpbWFYm1plbICZuOwhO+YClh\r\nn4c2fziizrIlOl1Mh2sZ8e0nytdOkOmo5P/bUlwnrml24/FrKTw09lK9Du0X\r\nDwlEB3INS63wPHy4L8kJocNJUDnr0lhNa67fvWBqbo1znKMPra6RJcgG/uVw\r\n+eXr+VN3azvQLRSWtPkgIBBvosZKAkp0NpZwapIFCyAoN4NannB/HejY156K\r\nO1YjwvjDbZi9R7hmGLSWZbDNFKgvlvy7idcF34lvORo//7eiiSV+HzGv9yT4\r\n6DP0M4IkWVYjkYntYEWelrJ77xXac65aqvcT4085ODRLtU9t9xtuBFIv7Phq\r\nKcQkiNd09uOPftIHLy383+4GZGs9LyFBeZw=\r\n=FMkz\r\n-----END PGP SIGNATURE-----\r\n","size":2299,"noattachment":false,"key":"/staged-components/-/staged-components-1.1.3.tgz"},"_npmUser":{"name":"awmleer","email":"awmleer@icloud.com"},"directories":{},"maintainers":[{"name":"awmleer","email":"awmleer@icloud.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/staged-components_1.1.3_1653622229191_0.9421982401568079"},"_hasShrinkwrap":false,"readme":"# Staged Components\n\nMake React function component staged.\n\n## Install\n\n```bash\nyarn add staged-components\n# or\nnpm install --save staged-components\n```\n\n## Usages\n\nReact Hook is awesome, but it has some kind of rules. One of these rules is [\"Only Call Hooks at the Top Level\"](https://reactjs.org/docs/hooks-rules.html#only-call-hooks-at-the-top-level).\n\nSo the component below will cause an error:\n\n```jsx\nconst App = function(props) {\n  if (props.user === undefined) return null\n  const [name, setName] = useState(props.user.name)\n  // React Hook \"useState\" is called conditionally. React Hooks must be called in the exact same order in every component render. Did you accidentally call a React Hook after an early return?\n  return (\n    <input value={name} onChange={(e) => {setName(e.target.value)}}/>\n  )\n}\n```\n\nWith `staged-components`, you can safely \"break\" this rule:\n\n```jsx\nconst App = staged((props) => { // stage 1\n  if (props.user === undefined) return null\n  return () => { // stage 2\n    const [name, setName] = useState(props.user.name)\n    return (\n      <input value={name} onChange={(e) => {setName(e.target.value)}}/>\n    )\n  }\n})\n```\n\n## Advanced\n\nUsage with `forwardRef`:\n\n```jsx\nconst App = forwardRef(staged((props, ref) => {\n  if (props.user === undefined) return null\n  return () => {\n    useImperativeHandle(ref, () => 'hello')\n    return (\n      <h1>{props.user.name}</h1>\n    )\n  }\n}))\n```\n","publish_time":1653622229436,"_cnpm_publish_time":1653622229436,"dist-tags":{"latest":"1.1.3"}}